display a modal form but keep the underlying thread processing

I have a timer in a form that triggers some processing functionality
When that gets triggered it displays a message to the user
So if the timer elapses a bunch of times i only want 1 message displayed on the screen at any time
When the message is displayed i need is to be modal
This is kind of weird but i need a modal messagebox plus i need a way to continue processing in the underlying thread
Its like a modal asynchronous call
i have no sample code
Any advice on how i could do this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I have a timer in a form that triggers some processing functionality
Make sure you are using a System.Threading.Timer and not a WinForms.Timer. The Threading.Time runs on a seperate thread from the UI. This will keep it running even when there is a modal UI displayed on the GUI.

So if the timer elapses a bunch of times i only want 1 message displayed on the screen at any time
Create a form level variable and give it the reference to the modal popup. The Threading.Timer will now fire a handler on a separate thread (never mind that the timer handler is sitting within the same class and file as your form :) ). In the handler, you must use an Invoke to check if the form is already displayed and handle that. Something like:
Private STTimer As System.Threading.Timer
Private NotificationForm As NotificationFormClass

Private Sub btnStart_Click(sender As Object, e As RoutedEventArgs)

	Me.STTimer = New Timer(AddressOf Me.TimerElapsed, Nothing, 1000, System.Threading.Timeout.Infinite)

End Sub

Private Sub TimerElapsed(state As Object)

	Dim message As String = String.Format("Tick Generated from {0}", Thread.CurrentThread.Name)
               'Code to check whether to display modal form or not
               If NotificationForm IsNot Nothing Then 
                      NotificationForm = New NotificationFormClass
                      'do what you want with the result etc etc
                      NotificationForm = Nothing
               End If
        End Sub, Action))

End Sub

Open in new window

These articles might also give you some further insights:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
glenn_rAuthor Commented:
i pasted the code into a sample winforms form and am having an error with the following line "Me.Dispatcher.Invoke(DirectCast(Sub()" it cannot find the dispatcher or namespace. I pasted this within a form class. thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.