[英]Form does not show without focus
我正在使用C#表單在Windows中顯示吐司樣式的通知(現有的氣球通知是錯誤的,無法滿足我的需要進行自定義)。
我在輪詢服務器上的更改時在子線程上調用以下代碼。
Thread notificationThread = new Thread(() =>
{
NotificationFrame notificationFrame = new NotificationFrame("text1", "text2");
notificationFrame.Show();
Application.Run();
});
notificationThread.Name = "Notification thread";
notificationThread.IsBackground = true;
notificationThread.Start();
但是,此表格並不總是顯示。 我發現只有在Visual Studio獲得焦點時它才起作用。 我嘗試在未附加調試器的情況下運行它,但這導致該窗體無法顯示。
例如。:
可能是隱藏的,請改用ShowDialouge()
Thread notificationThread = new Thread(() =>
{
NotificationFrame notificationFrame = new NotificationFrame("text1", "text2");
notificationFrame.Visible = true;
notificationFrame.ShowDialog();
Application.Run();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.