473,503 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to thread a class

Hi All

I'm wondering how to thread my control class. I've got a main GUI class
that calls to the control class to perform all the work ( database,
processing, printing, ect... ).

What I'm looking to do is to thread that control class so that the GUI
dosen't "freeze" when a intensive process is called.

I've threaded in java before but am not quite sure how to go about it in C#.
I pretty much want my control class the run in its own thread the entire
time the program is running. Is this bad?

Thanks

Bryan
Nov 15 '05 #1
3 1132
You idea is a fine one. Code like:

Thread SolverThread = new Thread(new ThreadStart(Solver));
SolverThread.Priority = ThreadPriority.BelowNormal;
SolverThread.Start();

will do the trick. Read the description of classes Thread and ThreadStart.
If you want your solver thread to put data to the UI you will need to use
Invoke.
"Bryan Masephol" <ma******@uwec.edu> wrote in message
news:e0**************@TK2MSFTNGP10.phx.gbl...
Hi All

I'm wondering how to thread my control class. I've got a main GUI class
that calls to the control class to perform all the work ( database,
processing, printing, ect... ).

What I'm looking to do is to thread that control class so that the GUI
dosen't "freeze" when a intensive process is called.

I've threaded in java before but am not quite sure how to go about it in C#. I pretty much want my control class the run in its own thread the entire
time the program is running. Is this bad?

Thanks

Bryan

Nov 15 '05 #2
May also want to take a look at the ThreadPool class.

"Bryan Masephol" <ma******@uwec.edu> wrote in message
news:e0**************@TK2MSFTNGP10.phx.gbl...
Hi All

I'm wondering how to thread my control class. I've got a main GUI class
that calls to the control class to perform all the work ( database,
processing, printing, ect... ).

What I'm looking to do is to thread that control class so that the GUI
dosen't "freeze" when a intensive process is called.

I've threaded in java before but am not quite sure how to go about it in C#. I pretty much want my control class the run in its own thread the entire
time the program is running. Is this bad?

Thanks

Bryan

Nov 15 '05 #3
Steven wrote:
May also want to take a look at the ThreadPool class.


Dot .NET is not like Java in that you have a JVM that works the same on all
on supported platforms. If you need to support Win98/WInME, not all methods
in the ThreadPool class are supported.

-Ed
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 10/29/2003
Nov 15 '05 #4

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

Similar topics

6
23707
by: Tomaz Koritnik | last post by:
I have a class that runs one of it's method in another thread. I use Thread object to do this and inside ThreadMethod I have an infinite loop: While (true) { // do something Thread.Sleep(100);...
4
1539
by: Daylor | last post by:
hi. i have multi thread application in vb.net is there a way NET support, so i can mark the class , to be access only for 1 thread each time ? if there is , small sytax sample will help ...
7
2671
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
2
1669
by: MIke Brown | last post by:
Hello all, I've been searching for a solution on google for a problem related to creating events from a worker thread, with no luck.. Basically, the problem is when my events are caught by a...
9
3258
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
4
6206
by: jayesah | last post by:
Hi All, I am writting a Thread class with using pthread library. I have some problem in saving thread function type and argument type. How to make Thread class generic ? /* This is my global...
8
1676
by: Carl Heller | last post by:
If I'm creating a class to do some work that I want threaded out, where's the best location to call ThreadStart? Or does it depend on the nature of the work? a. Call it outside the class,...
6
5101
by: HolyShea | last post by:
All, Not sure if this is possible or not - I've created a class which performs an asynchronous operation and provides notification when the operation is complete. I'd like the notification to be...
4
1411
by: fniles | last post by:
I create a thread where I pass thru a message. When I click very fast many times (like 50 times) to create 50 threads, the message did not get pass thru ProcessMessage. For example: strBuffer =...
9
3234
by: Pubs | last post by:
Hi all, I want to call a function with some intial parameters with in a thread. At the end of the function execution it should return a value to the caller. Caller is outside the thread. ...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
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,...
1
6991
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
7458
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...
0
5578
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
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
380
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...

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.