Hi,
I'm overriding WndProc to process some custom messages like so:
protected override void WndProc(ref Message m)
{
if (m.Msg == ImageFileMsg.MS G_IF_NEW_DATA)
{
ProcessNewDataM essage(m);
}
base.WndProc(re f m);
}
I receive one of these messages every 100ms or so for a few seconds.
This locks up my user interface completely until this is complete which
isn't ideal as each time I get a message I want to update a textbox on
my form.
I'm not sure if my solution is to use threading? I've never used
threads in .NET before, but my understanding is that if I use threading
I'll have to use delegates for my methods which update my form
controls, and these are all translated into messages which go through
WndProc. Is it possible for me to get my ProcessNewDataM essage to work
in a separate thread bearing in mind it's being called from WndProc? Or
will I encounter problems? 2 4085
Chris Ashley <ch***********@ gmail.comwrote:
I'm overriding WndProc to process some custom messages like so:
protected override void WndProc(ref Message m)
{
if (m.Msg == ImageFileMsg.MS G_IF_NEW_DATA)
{
ProcessNewDataM essage(m);
}
base.WndProc(re f m);
}
I receive one of these messages every 100ms or so for a few seconds.
This locks up my user interface completely until this is complete which
isn't ideal as each time I get a message I want to update a textbox on
my form.
I'm not sure if my solution is to use threading? I've never used
threads in .NET before, but my understanding is that if I use threading
I'll have to use delegates for my methods which update my form
controls, and these are all translated into messages which go through
WndProc. Is it possible for me to get my ProcessNewDataM essage to work
in a separate thread bearing in mind it's being called from WndProc? Or
will I encounter problems?
What does ProcessNewDataM essage need to do? If it's doing some
relatively heavy lifting, I suspect I'd extract all the relevant
information from the message, work on it in another thread (and there
are various options for doing that) and then update the UI using a
delegate. If ProcessNewDataM essage needs to do a lot of UI updating all
in one go, you might want to have a single delegate that takes all the
parameters it needs so you can do it all in one call. (That needn't
mean multiple parameters - it could be a single parameter of a new type
called something like UpdateInformati on which has all the relevant info
in it.)
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
"Chris Ashley" <ch***********@ gmail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
| Hi,
|
| I'm overriding WndProc to process some custom messages like so:
|
| protected override void WndProc(ref Message m)
| {
|
| if (m.Msg == ImageFileMsg.MS G_IF_NEW_DATA)
| {
| ProcessNewDataM essage(m);
| }
| base.WndProc(re f m);
| }
|
| I receive one of these messages every 100ms or so for a few seconds.
| This locks up my user interface completely until this is complete which
| isn't ideal as each time I get a message I want to update a textbox on
| my form.
|
| I'm not sure if my solution is to use threading? I've never used
| threads in .NET before, but my understanding is that if I use threading
| I'll have to use delegates for my methods which update my form
| controls, and these are all translated into messages which go through
| WndProc. Is it possible for me to get my ProcessNewDataM essage to work
| in a separate thread bearing in mind it's being called from WndProc? Or
| will I encounter problems?
|
What do you mean exactly with blocking your UI? If you really receive a
ImageFileMsg.MS G_IF_NEW_DATA message every 100 msec. and you update the
Textbox in your ProcessNewDataM essage(), which means that you update the UI
every 100 msec, this is not what I would call blocking the UI.
What's the service time of the method, and what exactly are you doing in
this method? Is the method CPU bound? Does it block etc... ?
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Zuel |
last post by:
Sup everyone!
I wrote this code for Tomcat appserver but I am told from an
associate that it has threading issues. The basic idea is to store a
read only data table for everyone to use. It takes some time for the
table to be created. I want to store the table in a singleton and
update it periodicly, basicaly when a user logs into the system. By
keeping 1 table allocated I don't have to worry about memmory usage
and if a user does...
|
by: Turbo_King |
last post by:
Hi,
I am trying to write a class which creates a window and then assigns a
method of the class as the wndproc function for the window so that
each instance of the class can handle the messages for its repective
form.
I am trying to do the following:
class myWinClass {
|
by: Michael Culley |
last post by:
I have some code that returns an event on a different thread. This is
causing all sorts of problems, so I would like to just call a method on the
main thread of the app and eliminate the second thread. The very first thing
I want to do anyway is show a modal window so I don't need a second thread.
Being that I know very little about threads can anyone gimme a solutions.
Thanks,
Michael Culley
|
by: Phuff |
last post by:
I have an application that should run in the system tray while open.
It is supposed to be open at all times and I need it to dissapear when
the "X" button is pushed on the form...but without closing the app.
I've tried overriding the closing event
> Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As
> System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
> 'Don't close this form
> e.Cancel = True
|
by: MuZZy |
last post by:
Hi,
I'm currently rewriting some functionality which was using
multithredaing for retrieving datasets from database and updating a grid
control. I found that the grids (Infragistics UltraGrid, though it
doesn't matter) were updated (i.e. grid.DataSource = dsDataSet;) and
used for different purposes in the worker thread, so now i'm wrapping
all those calls to grid's methods thru invoking which is a pain in the
a$$ considering number of...
| |
by: Christian Kaiser |
last post by:
We have a component that has no window. Well, no window in managed code - it
uses a DLL which itself uses a window, and this is our problem!
When the garbage collector runs and removes our component (created
dynamically by, say, a button click, and then not referenced any more), the
GC runs in a different thread, which prohibits the DLL to destroy its
window, resulting in a GPF when the WndProc of that window is called - the
code is gone...
|
by: Sin Jeong-hun |
last post by:
I created a windows form application. It has a Threading.Timer and when
the timer ticks it does some work and show a popup window.
The problem is that while this program is running if the user tries to
shutdown Windows, my application doesn't quit and neither does
Windows. Of course, if the user first click of my application and
then tries to shutdown, there is no problem.
To solve this problem, I overrode WndProc of the main form,...
|
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 glossing
it over. I've noticed that many of the postings on this board have to
do with threading and I...
|
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 database. I can potentially receive thousands,
|
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: 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: 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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |