Question

I'm building application that will stay in tray, from time to time it will do a service call and if service returns result it will show it as nice window in bottom right corner.
I found nice looking component as codeproject - http://www.codeproject.com/Articles/277584/Notification-Window this notification works good if it is used in forms application, but when I try to show it from ApplicationContext it stops my application - notification is showing, but when I try to click on it I get not response error.

class TrayContext : ApplicationContext
{
    private System.Timers.Timer appointmentTimer;
    private PopupNotifier notification;

    public TrayContext()
    {
        notification = new PopupNotifier
            {
                AnimationDuration = 500, 
                ContentFont = new System.Drawing.Font("Tahoma", 8F), 
                Image = null, 
                OptionsMenu = null, 
                Scroll = false, 
                ShowHandCursor = false, 
                Size = new System.Drawing.Size(400, 100), 
                TitleFont = new System.Drawing.Font("Segoe UI", 11.25F)
            };

        //timer
        appointmentTimer = new System.Timers.Timer();
        appointmentTimer.Interval = 600000;
        appointmentTimer.Elapsed += AppointmentTimerTimerElapsed;
        appointmentTimer.Start();
    }
    private void AppointmentTimerTimerElapsed(object sender, ElapsedEventArgs e)
    {
        appointmentTimer.Stop();
        notification.TitleText = "Test";
        notification.ContentText = "This should work";
        notification.Popup();
        appointmentTimer.Start();
    }
}

Here is behavior that I'm getting (cursor is busy not pointer): enter image description here

I was trying to do this using delegates, but because I'm using ApplicationContext I don't have BeginInvoke method, but even adding it like below didn't help:

private void BeginInvoke(Delegate callback, object[] args)
{
    syncContext.Post(state => callback.DynamicInvoke((object[])state), args);
}

I'm able to show this notification from Form, but how should I show it from ApplicationContext?

Was it helpful?

Solution

I've figured this out.

I was using:

private System.Timers.Timer appointmentTimer;

it should be:

private System.Windows.Forms.Timer appointmentTimer;

But there is probably better solution for this. I'm not marking my answer as correct because I'll wait bit longer for maybe better answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top