Click here to Skip to main content
15,891,981 members
Home / Discussions / C#
   

C#

 
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

GeneralRe: Microthreads Pin
Blake Coverett12-Oct-03 3:01
Blake Coverett12-Oct-03 3:01 
GeneralRe: Microthreads Pin
Bo Hunter12-Oct-03 7:05
Bo Hunter12-Oct-03 7:05 
GeneralRe: Microthreads Pin
bjoernen12-Oct-03 8:13
bjoernen12-Oct-03 8:13 
GeneralCOM+ and remoting Pin
devvvy11-Oct-03 23:31
devvvy11-Oct-03 23:31 
GeneralProblems with decrypting Pin
Wjousts11-Oct-03 18:08
Wjousts11-Oct-03 18:08 
GeneralBooks on C# Threading... Pin
eggie511-Oct-03 14:46
eggie511-Oct-03 14:46 
GeneralRe: Books on C# Threading... Pin
David Stone11-Oct-03 18:37
sitebuilderDavid Stone11-Oct-03 18:37 
GeneralRe: Books on C# Threading... Pin
Nick Parker12-Oct-03 11:10
protectorNick Parker12-Oct-03 11:10 
GeneralRemote events that instantiate and show new Forms Pin
jerrycainjr11-Oct-03 14:04
jerrycainjr11-Oct-03 14:04 
General3Tier applications and database replicating using C# Pin
DanFreddy11-Oct-03 11:57
DanFreddy11-Oct-03 11:57 
GeneralSerializing and Events Pin
jparsons11-Oct-03 9:49
jparsons11-Oct-03 9:49 
GeneralRe: Serializing and Events Pin
leppie11-Oct-03 23:22
leppie11-Oct-03 23:22 
GeneralRe: Serializing and Events Pin
jparsons12-Oct-03 13:31
jparsons12-Oct-03 13:31 
GeneralTypeInitializationException and Windows Service Pin
devvvy11-Oct-03 9:28
devvvy11-Oct-03 9:28 
GeneralGenerating public and private keys... Pin
Meysam Mahfouzi11-Oct-03 7:24
Meysam Mahfouzi11-Oct-03 7:24 
GeneralRe: Generating public and private keys... Pin
Blake Coverett11-Oct-03 10:17
Blake Coverett11-Oct-03 10:17 
GeneralRe: Generating public and private keys... Pin
Meysam Mahfouzi11-Oct-03 20:19
Meysam Mahfouzi11-Oct-03 20:19 

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.