473,419 Members | 4,382 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,419 software developers and data experts.

Multithreading trick needed

Dear all,
Is there some trick to put controls on a particular control but in other
thread.
Example:
A control is a part of bigger application and application thread freezes
somtimes. So a control freezes too. What I need is to spawn a thread and put
controls main thread in this thread.
Is it possible?
Thanks,
Boni
Nov 23 '05 #1
4 1219
Hi Boni

Not exactly what you were asking, but I would consider what is causing the
main thread to freeze, and look at putting that process onto another thread.
That way the main thread, and hence your controls remain responsive. It
could be much easier to do as well.

HTH

Charles
"Boni" <oilia@nospam> wrote in message
news:uC**************@TK2MSFTNGP09.phx.gbl...
Dear all,
Is there some trick to put controls on a particular control but in other
thread.
Example:
A control is a part of bigger application and application thread freezes
somtimes. So a control freezes too. What I need is to spawn a thread and
put controls main thread in this thread.
Is it possible?
Thanks,
Boni

Nov 23 '05 #2
Boni,

For this what you build is in VS2005 now the background worker.

Just to give the idea

Cor
Nov 23 '05 #3
Hi, Boni,
Having any UI (forms, controls or whatever) run on a thread other than the main foreground thread is generally Not A Good Thing To Do. It creates a host of headaches (race conditions, contentions, etc.) when trying to gain access to the various window resources available. It's far better to track down end eliminate whatever's causing the freeze-up.

That being said, there are certainly good uses for worker threads, and they can be leveraged to make your UI more responsive. I use them to take care of the number-crunching which doesn't impact the UI directly. So, for example, a user might click on a control and choose to do something performance intensive. What I do then it to disable the control after the click, spawn a thread and allow it to do the busy work, and when I'm informed that the thread has exited (via callback or message, whatever you like), I reenable the control and display whatever information is required. In the meantime, other controls can still be interacted with -- they're not frozen. I just need to be careful that nothing that those other controls do impacts any resources which that background thread requires. (Visual Studio itself works this way -- compilation, for example, occurs in a background thread so that you can still interact with the UI -- notably, "Cancel" among other things. The controls are still on the main thread; it's just the processing which is not.

The following link provides a general threading example:
http://msdn.microsoft.com/library/de...ingthreads.asp.

Hope this helps,

--Matt Gertz--*
VB Compiler Dev Lead
-----Original Message-----
From: Boni
Posted At: Tuesday, November 15, 2005 10:07 AM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: Multithreading trick needed
Subject: Multithreading trick needed
Dear all,
Is there some trick to put controls on a particular control but in other
thread.
Example:
A control is a part of bigger application and application thread freezes
somtimes. So a control freezes too. What I need is to spawn a thread and put
controls main thread in this thread.
Is it possible?
Thanks,
Boni
Nov 23 '05 #4
"Boni" <oilia@nospam> schrieb:
Is there some trick to put controls on a particular control but in other
thread.
Example:
A control is a part of bigger application and application thread freezes
somtimes. So a control freezes too. What I need is to spawn a thread and
put controls main thread in this thread.


Multithreading in Windows Forms applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #5

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

Similar topics

10
by: gianguz | last post by:
The question is about the possible use of inlining to improve performance in a heavy multithreading environment (200+ threads). If we have to work with applications in which threads aren't I/O...
47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
6
by: VM | last post by:
I'm trying to add multithreading to my win application but I'm having trouble with the code since the method to be threaded has parameters. How can I add multithreading to a method with parameters?...
7
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
20
by: Charles Law | last post by:
Consider the following scenario: A data packet is sent out of a serial port and a return packet is expected a short time later. The application sending the packet needs to send another packet...
5
by: Lucvdv | last post by:
Can anyone explain why this happens with the code at the bottom? It looked like a thread safety issue, but changing the declaration of Label1 to Shared doesn't help. Standard windows form;...
28
by: JV | last post by:
My ASP.NET application needs to accept data from a post and return quickly. I've added a worker thread to wake up and save data asynchronously after the data is received. But, it appears to me...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
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...

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.