我通过接口
从其他引用项目调用UI组件UI-成分:
Public Class PleaseWaitWindow
Implements PleaseWaitInterface
Sub New(initStateText As String)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
tbStateDescription.Text = initStateText
Me.Activate()
End Sub
Public Property currentStepText As String Implements PleaseWaitInterface.currentStepText
Get
Return tbStateDescription.Text
End Get
Set(value As String)
tbStateDescription.Text = value
tbStateDescription.InvalidateVisual()
End Set
End Property
Public Sub Display() Implements PleaseWaitInterface.Display
Me.Show()
Me.Activate()
End Sub
Public Sub Dispose() Implements PleaseWaitInterface.Dispose
Me.Close()
End Sub
Public Property maxSteps As Integer Implements PleaseWaitInterface.maxSteps
Get
Return pbCurrentProgress.Maximum
End Get
Set(value As Integer)
pbCurrentProgress.Maximum = value
End Set
End Property
Public Sub PerformStep() Implements PleaseWaitInterface.PerformStep
pbCurrentProgress.Value += 1
pbCurrentProgress.InvalidateVisual()
End Sub
End Class
只要我在同一个项目中进行这些调用,一切正常
喜欢这里:
Private Function startGeneration_normal() As Boolean
//Do some stuff
pw.PerformStep()
pw.currentStepText = ("Loading data, no stepping is available.")
tar.startworking(pw)
//Do some stuff
End Function
但是当我将Interfaceobject传递给引用的项目并试图像这样使用它时:
Public Function startworking(pw As PleaseWaitInterface) As Boolean
tempExportFileName = "Export" & DateTime.Now.ToString("yyyy-MM-dd_HH.mm")
//Do some stuff
pw.currentStepText = ("Current Task: formating XML")
//Do some more stuff
End Function
对象中的值发生更改(在调试器中检查),但直到start_generate函数从startworking函数返回后才会刷新视觉效果。当它从引用项目中的函数返回时,将根据当前状态刷新值。
为什么在程序执行引用项目中的内容时UI不会刷新?
答案 0 :(得分:0)
Clemens的解决方案,使用后台工作人员做了伎俩,所以
问题:
解决