"Emulation" Application.Run using Application.DoEvents

I have a problem's. I try to imitate the call to Application.Run using Application.DoEvents ... it sounds bad, and then I make alternative decisions on my question ...

I have to process a message pump, for example Application.Run, but I need to execute the code before and after processing the messages. Here is the main essential piece of code.

// Create barrier (multiple kernels synchronization)
sKernelBarrier = new KernelBarrier(sKernels.Count);

foreach (RenderKernel k in sKernels) {
    // Create rendering contexts (one for each kernel)
    k.CreateRenderContext();
    // Start render kernel kernels
    k.mThread = new Thread(RenderKernelMain);
    k.mThread.Start(k);
}

while (sKernelBarrier.KernelCount > 0) {
    // Wait untill all kernel loops has finished
    sKernelBarrier.WaitKernelBarrier();
    // Do application events
    Application.DoEvents();
    // Execute shared context services
    foreach (RenderKernelContextService s in sContextServices)
        s.Execute(sSharedContext);

    // Next kernel render loop
    sKernelBarrier.ReleaseKernelBarrier();
}

. Pratically , , OpenGL. , . , ( ), , Application.DoEvents() .

, ( ), 100% , Application.DoEvents(), Application.Run.

, ( ) , FPS; , .

?

: , OpenGL . Application.Run ...

+3
3

Application.DoEvents() . , Form.ShowDialog(). , , : , , .

, , , , , , - .

100% . - Thread.Sleep(1). .

+1
+1

, PInvoke Win32 ( , Application.Run - UnSafeNativeMethods, ).

- , , , - WaitMessage User32.dll , :

while (WaitMessage())
{
  Application.DoEvents();
}

, . VS, , , PInvoke.

0

Source: https://habr.com/ru/post/1739180/


All Articles