Hi WJScott,
the problem you are seeing is due to the fact that you are using the main
UI thread to perform a syncronous action that takes time to complete. While
this is running the UI thread has to wait and cannot perform the task of
updating the UI.
I would recommend running your long task in another thread, this way the
UI will still be responsive while the task is happening. Once the other
threads task has completed you can update the GUI - remember to call invoke
though on the control not update the GUI directly from the non UI thread i.e.
using System;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication3
{
public class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread worker = new Thread(new ThreadStart(DoLongTask));
worker.IsBackground = true;
worker.Start();
}
private void DoLongTask()
{
//This will pause the worker thread, not the main
//UI thread
System.Threading.Thread.Sleep(10000);
label1.Invoke(new LabelUpdateDelegate(UpdateLabel));
}
private void UpdateLabel()
{
this.label1.Text = "ALL DONE";
}
private delegate void LabelUpdateDelegate();
}
}
Hope that helps
Mark R Dawson
http://www.markdawson.org
"WJ*******@Yahoo.com" wrote:
I have written an application in C# and have everything I want working
except when I kick off the query to other machines VIA WMI it hangs
the app until it completes or I kill it. I know in VB there is a
fuction to use to allow the GUI to be interactive 9Move the window,
Cance by clicking a buttonm etc.) Is there such a function in C# to
unfreez the app I have and need desperatly to respond!!!