while(getting instruction received)
{
switch(instruction)
{
case startuploading:
if(workthread does not exist)
{
create workthread;
start workthread;
post message to workthread;
}
break;
....
case stopuploading:
{
post message to workthread;
}
break;
....
}
}
quit_mainthread()
{
post message to workthread;
cleanwork
}
}
workthread
{
while(getting instruction from mainthread)
{
switch(instruction)
{
case startuploading:
uploadingdata();
...
break;
....
case stopuploading:
stopuploadingdata();
...
break;
....
case quitworkthread:
stopuploadingdata();
...
break;
}
}