适用于初学者的C ++ Win32控制台中的多任务 [英] Multitasking in c++ win32 console for beginners

查看:59
本文介绍了适用于初学者的C ++ Win32控制台中的多任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,
我想问有关c ++ win32控制台多任务的问题.
我正在制作国际象棋游戏,程序已完成,但是我需要同时通过两个或三个任务添加动画.就像屏幕上某个地方的运行时间恒定一样,该程序也应该停止供用户输入.

http://www.tutorialspoint.com/cplusplus/cpp_multithreading.htm [

Hey,
I want to ask question about c++ win32 console multitasking.
I am working on making a game of chess, The program is completed, but i need to add animations by two or three tasks at the same time. Just like a constant running time somewhere on screen and the program should also stops for user input.

http://www.tutorialspoint.com/cplusplus/cpp_multithreading.htm[^]

I want something like this.This is much more easier. But I am unable to add pthread.h in visual studio 2010.

推荐答案

然后使用辅助线程.我建议您阅读 J.新手针对主题使用工作线程" [不要触摸UI规则).
Then use worker threads. I suggest you reading J. Newcomer''s assay on the topic "Using Worker Threads"[^] even if it is MFC oriented, you might gain some insight (e.g. the "don''t touch the UI rule").


如果这仅用于UI动画,则可以使用常规计时器,这是一个小教程:
计时器教程 [
If this is for UI animation only, you could use a regular timer, here is a small tutorial:
Timers Tutorial[^]

An event will be generated at intervals, lets say 100ms, which I guess will be good enough for your animations.

Best regards
Espen Harlinn


这篇关于适用于初学者的C ++ Win32控制台中的多任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆