Dispatcher xps memory leak

孤街醉人 提交于 2019-12-01 14:42:47

While it initially appears that the supplied code does nothing, it actually has a non-obvious side effect that is resolving your problem. Let's break it down into steps:

  • Dispatcher.CurrentDispatcher Gets the dispatcher for the current thread.
  • Invoke synchronously executes the supplied delegate on the dispatcher's thread (the current one)
  • DispatcherPriority.SystemIdle sets the execution priority
  • new DispatcherOperationCallback(delegate { return null; }) creates a delegate that does nothing
  • null is passed as an argument to the delegate

All together, this looks like it does nothing, and indeed it actually does do "nothing". The important part is that it waits until the dispatcher for the current thread has cleared any scheduled tasks that are higher priority than SystemIdle before doing the "nothing". This allows the scheduled cleanup work to happen before you return to your vb6 app.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!