Hello all,
Wonder what approach is used for this problem.
I have a MDIApplication, the MDIClinets are to be in a seperate thread.
So I've done something like this,
// Create a new Show method that starts a new thread
public new void Show()
{
Thread t = new Thread(new ThreadStart(Thr eadProc));
t.Start();
}
public void ThreadProc()
{
base.Show();
}
Now my problem is that I basically don't have a run loop, so as soon as the
Form shows the thread exits and I'm pretty much left in the soup.
I'm sure other people have done this in .NET?
Any ideas suggestions etc?
Thanks for you time
Brian Keating.
Nov 16 '05
12 5853
"Brian Keating EI9FXB" <csharp at briankeating.ne t> wrote in message
news:BF******** *************** ***********@mic rosoft.com... Ok guys, thanks for your help, I wonder if anyone has a suggestion on another approach.
Let me explain my problem, I've services running on my system, my application receives diagnostic messages from these services, what i want to do is create an MDIChild window for each service that sends a message.
Ok so far so good, but I get problems if one service is constantly sending messages to it's window because, this window is very busy updating it's view, hence because it's in the same thread at all other MDIChild windows and the MDIParent window the whole application is un responsive becasue this window is too busy.
I did manage to get the Multithread MDI working and stable in a C++ ATL/WTL application but it proved a heartache to say the least. I'd rather not go down that road again.
You should be able to handle this situation gracefully if you decouple the
window's UI operations (i.e., repaint) completely from the processing of
diagnostics messages. In other words, have the diagnostics message receiver
thread place the information into your own queue (or list, doesn't matter),
and then call Invalidate for the window (via Control.Invoke or BeginInvoke
to make it thread-safe).
If you really get lots of diagnostics messages and calling Invalidate is
still not good enough, then consider not calling Invalidate every time a
diagnostics message arrives. Simply place the diagnostics information into
your own queue and have the UI thread check the state of the queue e.g.,
once per second on a timer. This way you will get a refresh at a comfortably
slow rate no matter how fast the diagnostics messages arrive.
I'd go creating forms in multiple threads only as the very last resort.
Regards,
Sami
Hi Alex,
I've a test app created that used the Application.Run as you suggest,
this is pretty close to what I want, however i do get some events twice etc,
but I hope i'm getting close.
thanks for your help.
regards
Brian.
"AlexS" wrote: If you use MDI you have limit of one thread, which is UI distributing messages between child windows. I would go away from this paradigm.
You might be better off if you create forms on threads and use Application.Run for these forms. This seems to create separate message pumps and keeps windows pretty responsive if painting code is Ok. The only drawback I've seen so far is that you have to manage separate threads / forms as one applications - it adds some unnecessary complexity,
I am not sure why you want to have MDIChild for each service in one application. Service is separate process, so related standalone form seems to be natural companion.
HTH Alex
"Brian Keating EI9FXB" <csharp at briankeating.ne t> wrote in message news:BF******** *************** ***********@mic rosoft.com... Ok guys, thanks for your help, I wonder if anyone has a suggestion on another approach.
Let me explain my problem, I've services running on my system, my application receives diagnostic messages from these services, what i want to do is create an MDIChild window for each service that sends a message.
Ok so far so good, but I get problems if one service is constantly sending messages to it's window because, this window is very busy updating it's view, hence because it's in the same thread at all other MDIChild windows and the MDIParent window the whole application is un responsive becasue this window is too busy.
I did manage to get the Multithread MDI working and stable in a C++ ATL/WTL application but it proved a heartache to say the least. I'd rather not go down that road again.
Suggestions welcome. Thanks in advance Brian.
"Tom Shelton" wrote:
On 2004-11-25, Nigel Armstrong <Ni************ @discussions.mi crosoft.com> wrote: > Hi Tom > > How does this work with the "Thou Shalt have one User Interface thread per > application" rule - do we get a separate message pump for each MDI Child > window with this approach? > > Just interested really... > > Nigel Armstrong
Ooops! I missed the MDI part. No can do. This would cause definate issues. I think you'll need to change your design...
As for top level windows, yes, you get a message pump per thread.
-- Tom Shelton [MVP]
Hi Sami,
Tnx for your help, I'm still doing up a few tests so when I finally get a
"workable" solution I'll post an article on it.
thanks for your time.
Brian
"Sami Vaaraniemi" wrote: "Brian Keating EI9FXB" <csharp at briankeating.ne t> wrote in message news:BF******** *************** ***********@mic rosoft.com... Ok guys, thanks for your help, I wonder if anyone has a suggestion on another approach.
Let me explain my problem, I've services running on my system, my application receives diagnostic messages from these services, what i want to do is create an MDIChild window for each service that sends a message.
Ok so far so good, but I get problems if one service is constantly sending messages to it's window because, this window is very busy updating it's view, hence because it's in the same thread at all other MDIChild windows and the MDIParent window the whole application is un responsive becasue this window is too busy.
I did manage to get the Multithread MDI working and stable in a C++ ATL/WTL application but it proved a heartache to say the least. I'd rather not go down that road again.
You should be able to handle this situation gracefully if you decouple the window's UI operations (i.e., repaint) completely from the processing of diagnostics messages. In other words, have the diagnostics message receiver thread place the information into your own queue (or list, doesn't matter), and then call Invalidate for the window (via Control.Invoke or BeginInvoke to make it thread-safe).
If you really get lots of diagnostics messages and calling Invalidate is still not good enough, then consider not calling Invalidate every time a diagnostics message arrives. Simply place the diagnostics information into your own queue and have the UI thread check the state of the queue e.g., once per second on a timer. This way you will get a refresh at a comfortably slow rate no matter how fast the diagnostics messages arrive.
I'd go creating forms in multiple threads only as the very last resort.
Regards, Sami This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fabio Papa |
last post by:
I am trying to write a windows service that sends emails to clients at
specific times based on information in a sql db. Since this is done for
multiple cities, I start a thread for each city and continue the processing
from each thread. My service starts fine (gives me no errors, etc), but it
doesn't seem to start the new threads. I am new to windows services, so I
don't know if I'm doing something wrong. Should I maybe be doing this...
|
by: Brian Keating EI9FXB |
last post by:
I wonder can anyone reccomment a solution to this problem.
Let me explain, I've services running on my system, my
application receives diagnostic messages from these services, what i want to
do is create an MDIChild window for each service that is sending messages.
Ok so far so good, but I get problems if one service is constantly sending
messages to it's window because, this window is very busy updating it's view,
hence because it's...
|
by: vinoth |
last post by:
Hi,
I have created WindowsService Project.In that Project OnStart Method
i have written the following Code. In this code the Server is waiting
for the connection from client. When the Client connects to the Server,
the server will process and send result to the client.(This is Client
Server Application. The Server side Code is implementd in th OnStart
method Of Windows Service).
When i tried the Client Server Application in Console...
|
by: |
last post by:
Just a general question...
When working with a form containing a treeview or similar control... if you
need to show different form fields depending on what is selected in the
treeview then what is the best way to deal with these form controls...?
Like, when they are all visible in the designer it can be absolute chaos...
So how do you guys deal with it? Is there a blank container control (can't
see one) that allows you to drop a...
|
by: PAPutzback |
last post by:
How do I keep the form up.
| |
by: cbrown |
last post by:
I have a vb app that watches the COM port for incoming data. When it
sees that data it, it displays a form with a single label control on
it. When I call the form.Show() method, the form shows up, but the
label control does not draw and is transparent. Only if I do not open
the COM port does the label control draw (which of course defeats the
purpose). I am assuming I have to jump into multi-threading to correct
this, but my attempts...
|
by: Rykie |
last post by:
I am primarily a web developer, but have to develop this windows app.
It works a treat, but it has some places where it lags and some long
running processes, which I want to provide user feedback to the user
from.
I want to open a seperate windows form with an animation on it and a
label that is public so i can change the text on it as the process
progresses, but all I get is a blank form until the process is done.
Can someone please...
|
by: sekarm |
last post by:
Dear guys,
In C# windows application i am using four threads for seperate process. Each thread done seperate job.i want to monitor the thread process in main windows form.so each thread update data in windows controls in mainForm.By using this i got the exception "Cross thread operation not valid", so i am using Invoke method for access controls in mainform.by using this i am write if loop for invoke the control using...
|
by: Steve |
last post by:
Hi All
I have an on-screen keyboard within a POS program I have written in VB.net
2005, for touch screen computers
I have it set to 'always on top' so the user can move the cursor to
different text boxes and type using the on-screen keyboard
The keyboard launches via the mouseclick event for any text box
If another form is launched, with the onscreen keyboard still visible, the
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |