473,378 Members | 1,410 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,378 software developers and data experts.

windows message queue and breaking out of thread

(Relative newby)
Ive a secondary thread reading files from a serial port.
Ive also got a form with a progress bar informing the user on the status of
downloading the file. The progress delegate is called from the context of
the thread.
The form works fine if it's the topmost window but if it ever becomes
obscured by another application then it never gets invalidated/repainted
properly when it's redisplayed (even with lots of Thread.Sleep(0)s ).

So I thought I'd try to fix this by posting a user defined message from the
delegate to the form so that the progress message was handled in the context
of the application. (Im from a delphi background and we had to use
synchronize method of tthread when we wanted to update forms from worker
threads)

So, now I've found a Message struct and that I can overload the wndproc
function but I can't seem to find any info on the eqivalent of the
PostMessage function. Can someone help please.
Nov 16 '05 #1
2 2420
Claire <bl****@blahhhhh.com> wrote:
(Relative newby)
Ive a secondary thread reading files from a serial port.
Ive also got a form with a progress bar informing the user on the status of
downloading the file. The progress delegate is called from the context of
the thread.


Directly, or using Control.Invoke? You mustn't update a UI element
directly from any thread other than the one which created it.

See
http://www.pobox.com/~skeet/csharp/m...#windows.forms

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Thanks Jon,

Although you didn't answer about windows messages you've helped me
understand how to use invoke ( I searched for about an hour online about
that) I couldn't understand Microsofts help file on this method.
So I hope this solves it.

CC
Nov 16 '05 #3

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

Similar topics

29
by: Paul L. Du Bois | last post by:
Has anyone written a Queue.Queue replacement that avoids busy-waiting? It doesn't matter if it uses os-specific APIs (eg WaitForMultipleObjects). I did some googling around and haven't found...
4
by: Dan | last post by:
All, I have a windows service that creates a couple of worker threads to do some processing. The service works fine. However, the main service thread has a method for sending email notices that...
3
by: Brian Keating EI9FXB | last post by:
Hello again, I've already placed a few posts on this topic. This time i've a simple application that exhibits my problem, I've placed sample solution 8k on my website should anyone be interested...
8
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware...
5
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...
14
by: | last post by:
Hi All, I am little confused here, hope you can help me. While processing WM_POWERBROADCAST (wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy operation(30 sec) before system Suspends or...
4
by: Russell Warren | last post by:
I'm guessing no, since it skips down through any Lock semantics, but I'm wondering what the best way to clear a Queue is then. Esentially I want to do a "get all" and ignore what pops out, but I...
3
by: mohithmohith | last post by:
Hello All, We have around 3 windows services written in C#. We use them to process files from a folder into database and further to process the data into various SQL Tables. All the services...
9
by: mohitkumar | last post by:
Hello All, We have 3 windows services written in C#. We use them to process files from a folder into database and further to process the data into various SQL Tables. All the services hang...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.