By specifying 10 seconds as criteria, you are specifying the need for a timer. Why isn't a timer viable?
I must admit that this seems kinda silly, but here it goes:
using System;
using System.Windows.Forms;
using System.Threading;
public class FormSlideShow
{
private int complete = 0;
/// <param name="timeout">Number of milliseconds each form is shown.</param>
public void ShowForms(int timeout, params Form[] forms)
{
foreach (Form form in forms)
{
if (form.InvokeRequired)
form.Invoke(new MethodInvoker(form.Show));
else
form.Show();
// This should NOT be a System.Windows.Forms.Timer
// The callback is on a ThreadPool thread. Do not use the forms to call any Begin* inovcations or
// run any more Timer classes. (to prevent dead-locks)
using (System.Threading.Timer timer = new System.Threading.Timer(
new TimerCallback(HideForm), form, timeout, Timeout.Infinite))
{
while (complete == 0)
Application.DoEvents();
System.Threading.Interlocked.Exchange(ref complete, 0);
}
}
}
private void HideForm(object state)
{
Form form = state as Form;
try
{
if (form.InvokeRequired)
form.Invoke(new MethodInvoker(form.Close));
else
form.Close();
}
finally
{
System.Threading.Interlocked.Exchange(ref complete, 1);
}
}
}
--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"VB User" <VB****@discussions.microsoft.com> wrote in message news:68**********************************@microsof t.com...
I need to show few forms in sequential order, one after another with an
interval of approx 10 sec. What would be the best way out using Timers?