China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-25 18:33
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Question about multitasking programming under WinSail View 1,108 Replies 1
Original Poster Posted 2005-10-24 16:28 ·  中国 江苏 南京 电信
新手上路
Credits 3
Posts 1
Joined 2005-10-24 16:22
20-year member
UID 43986
Gender Male
Status Offline
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
ss6class@163.com
Floor 2 Posted 2005-10-25 18:46 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
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);
}
Forum Jump: