473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

HELP: Non-Responding Application

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!!!
Nov 17 '05 #1
1 1487
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!!!

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: D. Roshani | last post by:
Hello ! I wonder if any one can help me to create a cosomize sorting order (as Macro or added small program in c++ or c# which does this work) in a Access Database contaning one table only words...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Drewdog | last post by:
I am getting some error messages which I can't figure out their meaning. I have the code setup, I think it's correct but it doesn't work. My goal is to get this program to read from a data file and...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
0
by: tomwolfstein | last post by:
Hi. I am trying to write a wrapper for the standard VC1 decoder, and I need to resolve a "TypeLoadException" The decoder comes an an executable which I've turned into a .dll. This decoder has about...
12
by: Kira Yamato | last post by:
I've posted this in another thread, but I suppose I should've started a new thread for it instead. I cannot get the following short program to compile under g++: #include <iostream> #include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.