Windows Mobile 中的事件

本文关键字:事件 Mobile Windows | 更新日期: 2023-09-27 18:32:57

我正在使用一个事件来通知我的应用程序的处理进度。但是当我更新标签或进度时,在删除更新代码的同时没有更新

//update label 
void MUpdate_UpdateNotification(string Message)
{
    lblState.Invoke(UpdateLib.Notification.LabelDelegate, new object[] { lblState,  Message });
}
//delegate
public static LabeleAppendHandler LabelDelegate = new LabeleAppendHandler(UpdateLabel);
private static void UpdateLabel(System.Windows.Forms.Label lbl, string msg)
{
    lbl.Text = msg;
}
//how excute event
if (UpdateNotification!=null)
            UpdateNotification(Notification.GetNextStatus());

Windows Mobile 中的事件

Windows Mobile 默认在单个线程中运行,因此添加 Application.DoEvents(); 可以解决您的问题。

private static void UpdateLabel(System.Windows.Forms.Label lbl, string msg)
{
    lbl.Text = msg;
    Application.DoEvents();
}