Click here to Skip to main content
15,907,687 members
Home / Discussions / C#
   

C#

 
GeneralWebBrowser class Pin
Srikar Y12-Oct-03 19:11
Srikar Y12-Oct-03 19:11 
GeneralRe: WebBrowser class Pin
Kannan Kalyanaraman13-Oct-03 0:36
Kannan Kalyanaraman13-Oct-03 0:36 
GeneralCOM+ and remoting: Lifetime Pin
devvvy12-Oct-03 19:04
devvvy12-Oct-03 19:04 
GeneralLaunching GUI from Windows Service Pin
devvvy12-Oct-03 18:58
devvvy12-Oct-03 18:58 
GeneralRe: Launching GUI from Windows Service Pin
Randhir Sinha12-Oct-03 21:52
Randhir Sinha12-Oct-03 21:52 
GeneralHighliting text Pin
Srikar Y12-Oct-03 18:31
Srikar Y12-Oct-03 18:31 
Questionhow to catch exception throw inside in worker thread? Pin
zecodela12-Oct-03 16:31
zecodela12-Oct-03 16:31 
AnswerRe: how to catch exception throw inside in worker thread? Pin
Randhir Sinha12-Oct-03 22:04
Randhir Sinha12-Oct-03 22:04 
GeneralRe: how to catch exception throw inside in worker thread? Pin
zecodela12-Oct-03 22:19
zecodela12-Oct-03 22:19 
GeneralRunning forms on seperate thead Pin
SharpKnight12-Oct-03 11:34
SharpKnight12-Oct-03 11:34 
GeneralRe: Running forms on seperate thead Pin
12-Oct-03 21:33
suss12-Oct-03 21:33 
GeneralPInvoke CreateProcess Pin
devvvy12-Oct-03 9:31
devvvy12-Oct-03 9:31 
GeneralRe: PInvoke CreateProcess Pin
devvvy12-Oct-03 9:54
devvvy12-Oct-03 9:54 
GeneralRe: PInvoke CreateProcess Pin
J. Dunlap12-Oct-03 9:57
J. Dunlap12-Oct-03 9:57 
GeneralRe: PInvoke CreateProcess Pin
devvvy12-Oct-03 10:00
devvvy12-Oct-03 10:00 
GeneralPInvoke CWnd Pin
devvvy12-Oct-03 10:24
devvvy12-Oct-03 10:24 
GeneralRe: PInvoke CWnd Pin
J. Dunlap12-Oct-03 10:48
J. Dunlap12-Oct-03 10:48 
GeneralRe: PInvoke CWnd Pin
devvvy12-Oct-03 10:52
devvvy12-Oct-03 10:52 
GeneralRe: PInvoke CWnd Pin
Nick Parker12-Oct-03 11:00
protectorNick Parker12-Oct-03 11:00 
GeneralRe: PInvoke CWnd Pin
devvvy12-Oct-03 11:06
devvvy12-Oct-03 11:06 
Generaladding components to the designer by code Pin
Roger Alsing12-Oct-03 2:40
Roger Alsing12-Oct-03 2:40 
GeneralRe: adding components to the designer by code Pin
Rod O12-Oct-03 5:03
Rod O12-Oct-03 5:03 
GeneralRe: adding components to the designer by code Pin
Roger Alsing12-Oct-03 22:10
Roger Alsing12-Oct-03 22:10 
GeneralCOM+ Pin
devvvy12-Oct-03 1:20
devvvy12-Oct-03 1:20 
GeneralMicrothreads Pin
bjoernen12-Oct-03 0:58
bjoernen12-Oct-03 0:58 
I have an application that consists of a lot of concurrently executing controllers that performs many different time consuming or timed operations. To get an idea what this means practically, you can imagine 10000 threads (each controller), where each thread performs the timed operations by the use of calls/callbacks.

I want to move to some other paradigm. I want a way of simulating several threads (microthreads) and a way of writing C# code that not gets messy by a lot of callback handling.

What I have at the moment is this, for each operation the controller should perform:

void DoOperationX()
{
// Do some stuff or initiate something
}

void OperationXDoneCallBack()
{
// Stuff is done, move to next operation:
DoOperationX+1();
}

What I would like to write code-wise, is the following for each controller. And I would like to simulate concurrent execution of all controllers, only using one real thread (or a few real threads):

void PerformOperations()
{
DoOperation1(); // Perform operation 1, and wait until its done
DoOperation2(); // Perform operation 2, and wait until its done
DoOperation3(); // Perform operation 3, and wait until its done
}

1. How do I simulate microthreads? I can live with the need of calling a special method once in a while to check if the microthread should be paused and execution should be given to the next microthread. Is there a way to copy the current stack and restore it later?

2. Callback hiding. If I can get the microthreading to work, I can hide the callbacks from the API like this:

void DoOperationX()
{
DoTheOperation();

while (!callBackXDone)
{
CheckMicroThread(); // Switch microthread if needed.
}
}

void OperationXCallBack()
{
callBackXDone = true;
}

Am I following the wrong path here? Is there already a simple solution to this?

Regards, Björn

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.