我在SO和其他地方看到过几个类似的问题,但似乎没有一个适合我。WPF:等待动画窗口块
我在我的项目中有一个小的Window
,其中包含我在应用程序启动时显示的LoadingAnimation并希望保持实际处理运行。这里是我的启动代码:
Dim WaitWindow As New WaitWindow("Loading application...")
WaitWindow.Show()
LongRunningLoading()
WaitWindow.Close()
这里的LongRunningLoading()
功能,我尝试在一个单独的线程运行,以避免阻塞我的动画:
Private Function LongRunningLoading() As Boolean
Dim resetEvent As New System.Threading.ManualResetEvent(False)
Dim RetVal As Boolean = False
ThreadPool.QueueUserWorkItem(Sub(state)
'DO SOMETHING AND RETURN RESULTS
resetEvent.Set()
End Sub,
RetVal)
resetEvent.WaitOne()
Return RetVal
End Function
一切正常,只是加载动画不玩了。我究竟做错了什么?
不是QueueUserWorkItem()启动一个新的线程? – dotNET 2013-02-25 07:16:15