0

I have a Windows Forms application using .NET 4.5.2 and I'm creating a PopupNotifier that I create in code:

PopupNotifier popup = new PopupNotifier();

popup.TitleText = "Title here";
popup.ContentText = "Content here";

popup.Popup();

This popup is meant to alert the user of 'milestones' in the application's progress when the application was called as a scheduled task with no visible GUI, which I'm hiding with the following code when the form loads:

BeginInvoke(new MethodInvoker(delegate {
    Hide();
}));

The problem is that all the popups back up in a queue or something. It appears they won't popup until the method they were called in finishes executing, and the UI thread is again the primary processing focus as the application is more or less idle. But I'm not sure exactly why.

I've tried solutions such as invoking the popup from the form's UI thread like suggested in this answer with no luck. Is there a line or block of code I can call to force the popup to show? Something like Application.DoEvents() (except, you know, something that works to force the popup to show).

Thanks for the help!

Chad
  • 1,531
  • 3
  • 20
  • 46
  • Is it a Windows Forms application of WPF application? – user1451111 Sep 04 '18 at 03:44
  • It is a Windows Forms application using .NET 4.5.2 - I've updated my question with this information. – Chad Sep 04 '18 at 17:40
  • If you don't need a GUI for a Windows Forms application and wants to run it as a scheduled task, why not create a Windows Service instead of a Windows Forms app? – user1451111 Sep 05 '18 at 05:27
  • It has a GUI but the scheduled task should run without the GUI being displayed. – Chad Sep 06 '18 at 01:11
  • Have you looked into the `BackgroundWorker` class? It was specifically designed to provide multi-threading in Windows Forms applications. – user1451111 Sep 06 '18 at 03:59
  • I've looked at it and that may have to be the route I take, but I would really like to know if there's a way to force this popup to show on the screen. As soon as the current method finishes processing it shows up, but the method has a for loop and I'd like to alert the user with each iterated, completed task instead of at the end. – Chad Sep 07 '18 at 21:11
  • so in short, you want a Windows-style popup or alert box near task bar, for a scheduled program with no GUI? – user1451111 Sep 08 '18 at 08:49
  • Yes, which is why I'm using the Tulpep PopupNotifier library. But the popups need to show up whether or not the GUI is visible. – Chad Sep 08 '18 at 20:46

0 Answers0