473,563 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threading question

Hello!

I've got a class, representing Windows Form (Form1);
When I launch new thread user interface e.g. Form1 stops responding until
the worker thread is completed.

So the question - how this can be avoided. Roughly speaking I need to
perform some job after the button click and while this job is completing
user GUI can respond.

Here is the code I'm using:
ThreadStart threadStart = new ThreadStart(DoS omething);

Thread thread = new Thread (threadStart);
thread.Start();

In the debuger thread.Start() returns immediately. But GUI freezes until the
work thread is completed.
--
Vadym Stetsyak
ICQ 161730125

He, who commands the past - commands the future
He, who commands the present - commands the past
Nov 13 '05 #1
2 5796
"Vadym Stetsyak" spoke:
Hello!

I've got a class, representing Windows Form (Form1);
When I launch new thread user interface e.g. Form1 stops responding
until the worker thread is completed.

So the question - how this can be avoided. Roughly speaking I need to
perform some job after the button click and while this job is
completing user GUI can respond.

Here is the code I'm using:
ThreadStart threadStart = new ThreadStart(DoS omething);

Thread thread = new Thread (threadStart);
thread.Start();

In the debuger thread.Start() returns immediately. But GUI freezes
until the work thread is completed.


Does "DoSomethin g" try to access UI components? That is *not* allowed.
For a general introduction into the whole topic, check out
http://msdn.microsoft.com/msdnmag/is...ing/default.as
px

Cheers,
--
Joerg Jooss
jo*********@gmx .net
Nov 13 '05 #2
Actually yes. I am quite a newbie to Windows Forms and C#.
Thanks for the answer.

"Joerg Jooss" <jo*********@gm x.net> wrote in message
news:ut******** ******@TK2MSFTN GP10.phx.gbl...
"Vadym Stetsyak" spoke:
Hello!

I've got a class, representing Windows Form (Form1);
When I launch new thread user interface e.g. Form1 stops responding
until the worker thread is completed.

So the question - how this can be avoided. Roughly speaking I need to
perform some job after the button click and while this job is
completing user GUI can respond.

Here is the code I'm using:
ThreadStart threadStart = new ThreadStart(DoS omething);

Thread thread = new Thread (threadStart);
thread.Start();

In the debuger thread.Start() returns immediately. But GUI freezes
until the work thread is completed.


Does "DoSomethin g" try to access UI components? That is *not* allowed.
For a general introduction into the whole topic, check out
http://msdn.microsoft.com/msdnmag/is...ing/default.as
px

Cheers,
--
Joerg Jooss
jo*********@gmx .net

Nov 13 '05 #3

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

Similar topics

65
6683
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace,...
19
6449
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException. "somethread.interrupt()" will wake somethread up when it's in sleeping/waiting state. Is there any way of doing this with python's thread? I suppose thread...
3
1488
by: David Harrison | last post by:
I am working on an application on Mac OS X that calls out to python via PyImport_ImportModule(). I find that if the imported module creates and starts a python thread, the thread seems to be killed when the import of the module is complete. Is this expected? Does python have to be in control to allow threads to run? Would it be better to...
4
1581
by: Antal Rutz | last post by:
Hi, All! I'm new to threading. I have some design questions: Task: I collect data and store them in an RDBMS (mysql or pgsql) The question is how to do that with threading? The data-collecting piece of the code runs in a thread. 1. Open the db, and each thread writes the result immediately. (Sub-question: which is better: cursor object...
6
555
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service and the final process(3) gets called. what am I doing wrong with the threading? by the way Directory.GetFiles(IncomingXMLPath1).Length is some...
7
318
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, Anthony Nystrom
4
1294
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to process messages coming out of a thread? I want to queue them up, but MessageQueue doesn't look like what I need. Should I just make my own queue...
4
321
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In this method, I iniate a PROCESS and on completion, it reduces the available worker thread and continue. I have couple of questions; 1. Since I...
4
1586
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered threading. The instructor is of the opinion that threading is not very useful and glossed over the subject. At least he admitted that he was...
19
1792
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. Threading is a new concept for me to implement. Here is my problem. I have a system that receives xml files and records their file locations in a...
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.