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

user defined window message

I have an app that has several background threads running, and I want to use
a user-defined message to tell the main form that I want it to update a
object it created on startup.

I know this capability is in VC++ using the RegisterMessage and PostMessage
functions, but is there anything like this in VB.net?

Thanks.
Jan 24 '08 #1
3 1319
On 2008-01-24, Nathan Smith <Na*********@discussions.microsoft.comwrote:
I have an app that has several background threads running, and I want to use
a user-defined message to tell the main form that I want it to update a
object it created on startup.

I know this capability is in VC++ using the RegisterMessage and PostMessage
functions, but is there anything like this in VB.net?

Thanks.
You can certainly use RegisterMessage and PostMessge from VB.NET using
P/Invoke - but, wouldn't it be simpler to just let your background
threads fire an event back to the main thread?

--
Tom Shelton
Jan 24 '08 #2

"Tom Shelton" <to*********@YOUKNOWTHEDRILLcomcast.netwrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
On 2008-01-24, Nathan Smith <Na*********@discussions.microsoft.comwrote:
>I have an app that has several background threads running, and I want to
use
a user-defined message to tell the main form that I want it to update a
object it created on startup.

I know this capability is in VC++ using the RegisterMessage and
PostMessage
functions, but is there anything like this in VB.net?

Thanks.

You can certainly use RegisterMessage and PostMessge from VB.NET using
P/Invoke - but, wouldn't it be simpler to just let your background
threads fire an event back to the main thread?
The thing to be wary of when using events or a direct notification is that
the call will then need to be marshalled over to the UI thread. This can be
achieved a couple of ways, such as using the BackgroundWorker component for
the background threads, or using normal threading and then doing an
Control.Invoke call to get the message onto the main thread.

Jan 24 '08 #3
"Nathan Smith" <Na*********@discussions.microsoft.comschrieb::
>I have an app that has several background threads running, and I want to
use
a user-defined message to tell the main form that I want it to update a
object it created on startup.

I know this capability is in VC++ using the RegisterMessage and
PostMessage
functions, but is there anything like this in VB.net?
You do not even need 'RegisterWindowMessage' if you are sending messages
inside your application. Instead, you can define your own messages with
message codes in the range &H8000 through &HBFFF.

However, I am just curious why you are not using
'Control.Invoke'/'Control.BeginInvoke'/'Control.InvokeRequired' instead to
access the controls from within the threads.

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

Jan 25 '08 #4

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

Similar topics

4
by: Mountain Man | last post by:
Hi, I'm trying to use window.open from inside a user defined function, and it's not working. A code example is shown below. Thanks for any help you can give. Mountain Man ============ ...
2
by: David Emme | last post by:
Access 97 I have a number of SELECT statements which contain references to user-defined VBA functions. These typically work as expected, but occasionally, on one user's machine or another,...
5
by: Chris | last post by:
Hi everyone, I have an error message in an Access 97 database & I was hoping someone may be able to help me get rid of it (bearing in mind I only have an average understanding of Access &...
3
by: Regnab | last post by:
Despite having at least 2 days VBA programming experience, this one has got me... I'm trying to export multiple tables into one worksheet in Excel. I've adapted code that I've got from this forum,...
3
by: raphtee | last post by:
This is probably a simple/stupid question, but... I have an MDI application which has a socket receiving data. When the data is received it is displayed in some way. Sometimes the data that is...
4
by: Samy | last post by:
Hi There, I have a user control with a textbox and a button which when clicked opens a calendar control(calendar.aspx page). When I select a date from the calendar control, the date is supposed to...
0
by: tony | last post by:
Hello! For some month ago I created a project using template Window Control Library. From this template I created a user control(DLL) that I have in the toolbox and can drag it into a window...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
2
by: jr | last post by:
Hello everyone! I am new to this sort of postings so I'm not even sure if this is the correct place to start. Anyway, I would realy appreciate any help. I have a some VBA code that works quite...
3
by: =?Utf-8?B?RXJpYw==?= | last post by:
When porting the Win32/MFC code to C#, I do not know how to deal with those user defined windows messages. I just cannot cannot find an equivalent thing in C#. Those messsages are so convenient in...
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.