English 中文(简体)
Porting Settimer() and Killtimer() to C#?
原标题:Porting SetTimer() and KillTimer() to C#?

我试图将一些法典从C++到C#。

我在《C++法典》中就这样说:

watchdogTimer = SetTimer(1,1000,NULL);
...
KillTimer(watchdogTimer);

该法典做了哪些工作,以及如何把这带至C#?

感谢。

最佳回答

CWnd:Settimer function You ooking at Creats a timer that sents WM_TIMER activities to the即窗口。 这与 部分,载于NET。 其行为与<代码>略有不同。 系统、时间设计/编码。 有两个特别相关的差别:

Windows.Forms.Timer calls the event handler on the UI thread. By default, System.Timers.Timer calls the event handler on a threadpool thread. You can use SynchronizingObject property to have the System.Timers.Timer call on the UI thread.

Another difference is that it s not possible to encounter reentrancy problems with the Windows Forms timer because Windows won t allow multiple WM_TIMER messages from the same timer in the queue, nor will it place a WM_TIMER message in the queue if one is already being processed. This is generally a good thing.

<代码>Systemrs.timer, 而另一方面,允许重新使用。 因此,如果你花时间比时间更长,你可以同时处理多个事件。 如果你的时间长度为100米,处理时间为150米,你在重新处理第一期报告时将再次收到通知。 如果你使用<条码>SynchronizingObject,以迫使电离层膜炎的警示,这可能导致一整块待发的警示。

两个时间者的实施差别很大。 视像仪使用旧风格。 视窗时间为20年左右。 这类时间需要一个窗口处理和一个信息循环,因此只能在全球倡议方案中使用。

问题回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签