![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-10-31 21:43 |
47,815 topics / 349,930 posts / today 0 new / 48,290 members |
| DOS开发编程 & 发展交流 (开发室) » Question about multitasking programming under WinSail |
| Printable Version 1,280 / 1 |
| Floor1 ss6class | Posted 2005-10-24 16:28 |
| 新手上路 Posts 1 Credits 3 | |
|
Does any expert here have experience using winsail (an industrial control development system) to write multitasking programs that run under DOS? Could you send me a related piece of code to take a look at? Thanks. You can also send it to my email
[email protected] |
|
| Floor2 firstsail | Posted 2005-10-25 18:46 |
| 高级用户 Posts 295 Credits 668 From 广东深圳 | |
|
1: In the Config.Sys file:
[System] MultiTask = TRUE ;requires multitasking support 2: In the Main program #include <Symbol.h> #include <MyFrame.h> //Default virtual keyboard function for all windows void far TransrateKey(CObject* pObject) { return(0); } int far MyThread1(DWORD dwParam) { WORD k = 0; //The AfxKbhit function is the multitasking version, an upgraded kbhit() while(!::AfxKbhit()) { if ((k % 60) == 0) { ::sound(500); } else if ((k % 60) == 30) { ::nosound(); } k++; } } void far MyDebugFunction() { //Press any key to exit this function while (!AfxKbhit()) { } } //Main program int main(int argc, char** argv) { //Register the multitasking kernel that comes with WinSail ::AfxRegisterMultitaskEntry( ::KernalInitProcess, ::KernalCloseProcess, ::__MultiTaskDelay); //Initialize system functions if (!::InitSystem(argc, argv)) { ::CloseSystem(); ::printf("\nInit System Error"); return(0); } //At this point, the main program has already become thread 0! //... //You can start your own thread here if ( -1 == ::AfxBeginProcess(MyThread1, NULL, DEFAULT_STACK_SIZE)) { //Error handling } //Your work below ::MyDebugFunction(); //Close the system ::CloseSystem(); //Note: when process 0 closes, all processes will be forcibly closed, dangerous! return(0); } |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |