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

How to queue message to self? (C#)

What is the C# equivalent to calling PostMessage() in Win32 in order for an
object to queue a message to itself?
Thanks
Mountain
Nov 15 '05 #1
6 1858
I guess the answer is the same as every previous time it was asked ;)
http://groups.google.com/groups?hl=e...TF-8%26hl%3Den

However, that doesn't seem very satisfactory for C#.

Is there a nice way to do this using delegates? What I want to do is queue
an event (with args derived from EventArgs) that my object will then handle
when it finishes with it's current processing. Any other suggestions? (BTW,
my objects are all normal classes, not Forms, Controls, etc.)

Thanks,
Mountain
What is the best newsreader?

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:yXkEb.582999$HS4.4336412@attbi_s01...
What is the C# equivalent to calling PostMessage() in Win32 in order for an object to queue a message to itself?
Thanks
Mountain

Nov 15 '05 #2
100
Hi Mountain,
Whar you are looking for is Control.BeginInvoke. When called for the thread
owning the control it works lamost like PostMessage with a slight
difference. The difference is that with BeginInvoke the next thing that is
going to be executed from the thread will be the delegate you provide to the
BeginInvoke method. With post message your message will be queued and will
wait its time to come.

HTH
B\rgds
100

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:R2lEb.594304$Fm2.545394@attbi_s04...
I guess the answer is the same as every previous time it was asked ;)
http://groups.google.com/groups?hl=e...TF-8%26hl%3Den
However, that doesn't seem very satisfactory for C#.

Is there a nice way to do this using delegates? What I want to do is queue
an event (with args derived from EventArgs) that my object will then handle when it finishes with it's current processing. Any other suggestions? (BTW, my objects are all normal classes, not Forms, Controls, etc.)

Thanks,
Mountain
What is the best newsreader?

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:yXkEb.582999$HS4.4336412@attbi_s01...
What is the C# equivalent to calling PostMessage() in Win32 in order for

an
object to queue a message to itself?
Thanks
Mountain


Nov 15 '05 #3
Hi 100,
Any other ideas? I'm not using Controls or Forms. Also, I want the message
queued.
Thanks,
Mountain

"100" <10*@100.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Mountain,
Whar you are looking for is Control.BeginInvoke. When called for the thread owning the control it works lamost like PostMessage with a slight
difference. The difference is that with BeginInvoke the next thing that is
going to be executed from the thread will be the delegate you provide to the BeginInvoke method. With post message your message will be queued and will
wait its time to come.

HTH
B\rgds
100

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:R2lEb.594304$Fm2.545394@attbi_s04...
I guess the answer is the same as every previous time it was asked ;)

http://groups.google.com/groups?hl=e...TF-8%26hl%3Den

However, that doesn't seem very satisfactory for C#.

Is there a nice way to do this using delegates? What I want to do is queue an event (with args derived from EventArgs) that my object will then

handle
when it finishes with it's current processing. Any other suggestions?

(BTW,
my objects are all normal classes, not Forms, Controls, etc.)

Thanks,
Mountain
What is the best newsreader?

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:yXkEb.582999$HS4.4336412@attbi_s01...
What is the C# equivalent to calling PostMessage() in Win32 in order
for an
object to queue a message to itself?
Thanks
Mountain



Nov 15 '05 #4
100
Ok, It seems like I was mislead by the post's subject.
In this case I'm not quite sure what you want to achive. Controls are the
parts of the framework that gives you the event driven nature of the
application. IMHO only when the application works in event-driven fashion
posting messages to itself make sense. However, you can always have a list
of references to delegate objects to queue your job items and when your
code finishes its current processing it can pull the next delegate form the
list and execute its method(s). Posting messages (delegates) is simply
adding the delegate to the list - to the head or to the tail depending on
the priority you wants to give to the work item.

B\rgds
100
"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:rtHEb.402123$Dw6.1250132@attbi_s02...
Hi 100,
Any other ideas? I'm not using Controls or Forms. Also, I want the message
queued.
Thanks,
Mountain

"100" <10*@100.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Mountain,
Whar you are looking for is Control.BeginInvoke. When called for the

thread
owning the control it works lamost like PostMessage with a slight
difference. The difference is that with BeginInvoke the next thing that is
going to be executed from the thread will be the delegate you provide to

the
BeginInvoke method. With post message your message will be queued and will wait its time to come.

HTH
B\rgds
100

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:R2lEb.594304$Fm2.545394@attbi_s04...
I guess the answer is the same as every previous time it was asked ;)

http://groups.google.com/groups?hl=e...TF-8%26hl%3Den

However, that doesn't seem very satisfactory for C#.

Is there a nice way to do this using delegates? What I want to do is queue an event (with args derived from EventArgs) that my object will then

handle
when it finishes with it's current processing. Any other suggestions?

(BTW,
my objects are all normal classes, not Forms, Controls, etc.)

Thanks,
Mountain
What is the best newsreader?

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:yXkEb.582999$HS4.4336412@attbi_s01...
> What is the C# equivalent to calling PostMessage() in Win32 in order for an
> object to queue a message to itself?
> Thanks
> Mountain
>
>



Nov 15 '05 #5

"100" <10*@100.com> wrote in message
news:e7**************@TK2MSFTNGP09.phx.gbl...
Ok, It seems like I was mislead by the post's subject.
In this case I'm not quite sure what you want to achive. Controls are the
parts of the framework that gives you the event driven nature of the
application.
100, thanks for your thoughts on this. I just want to clarify a few
additional points and respond with
a different point of view.
First, of course, event handling is certainly not limited to Controls and
Control-derived objects.
IMHO only when the application works in event-driven fashion
posting messages to itself make sense.
Yes, but why assume this is limited to working with Controls? In my current
app, for example, we have collections that are changed as a result of
computations, and changes in these collections generate events. This is a
fully reactive (event-driven) system that is completely separate from any
GUI. Futhermore, check out Acitive Oberon for .NET. It is a language based
on the active object paradigm and it shows that the concept of being
event-driven need not be tied only to the GUI.
However, you can always have a list
of references to delegate objects to queue your job items and when your
code finishes its current processing it can pull the next delegate form the list and execute its method(s).
I'm hoping to leverage the event-queuing already built into Windows.
Posting messages (delegates) is simply
adding the delegate to the list - to the head or to the tail depending on
the priority you wants to give to the work item.
Good points, but I still wish to use the existing infrastructure for events
rather than reinvent the wheel. Too bad PostMessage() doesn't have a
pre-built dotnet wrapper.

What is the right way to use PostMessage to post a message of a user-defined
object type?

B\rgds
100
"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:rtHEb.402123$Dw6.1250132@attbi_s02...
Hi 100,
Any other ideas? I'm not using Controls or Forms. Also, I want the message
queued.
Thanks,
Mountain

"100" <10*@100.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Mountain,
Whar you are looking for is Control.BeginInvoke. When called for the thread
owning the control it works lamost like PostMessage with a slight
difference. The difference is that with BeginInvoke the next thing that is going to be executed from the thread will be the delegate you provide
to
the
BeginInvoke method. With post message your message will be queued and will wait its time to come.

HTH
B\rgds
100

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:R2lEb.594304$Fm2.545394@attbi_s04...
> I guess the answer is the same as every previous time it was asked
;) >

http://groups.google.com/groups?hl=e...TF-8%26hl%3Den
>
> However, that doesn't seem very satisfactory for C#.
>
> Is there a nice way to do this using delegates? What I want to do is

queue
> an event (with args derived from EventArgs) that my object will then
handle
> when it finishes with it's current processing. Any other suggestions? (BTW,
> my objects are all normal classes, not Forms, Controls, etc.)
>
> Thanks,
> Mountain
> What is the best newsreader?
>
> "Mountain Bikn' Guy" <vc@attbi.com> wrote in message
> news:yXkEb.582999$HS4.4336412@attbi_s01...
> > What is the C# equivalent to calling PostMessage() in Win32 in

order for
> an
> > object to queue a message to itself?
> > Thanks
> > Mountain
> >
> >
>
>



Nov 15 '05 #6
Hi 100,
I ended up taking your suggestion and implementing a queue of delegates.
Thanks!
Mountain

"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:DsZEb.408165$Dw6.1264963@attbi_s02...

"100" <10*@100.com> wrote in message
news:e7**************@TK2MSFTNGP09.phx.gbl...
Ok, It seems like I was mislead by the post's subject.
In this case I'm not quite sure what you want to achive. Controls are the
parts of the framework that gives you the event driven nature of the
application.
100, thanks for your thoughts on this. I just want to clarify a few
additional points and respond with
a different point of view.
First, of course, event handling is certainly not limited to Controls and
Control-derived objects.
IMHO only when the application works in event-driven fashion
posting messages to itself make sense.


Yes, but why assume this is limited to working with Controls? In my

current app, for example, we have collections that are changed as a result of
computations, and changes in these collections generate events. This is a
fully reactive (event-driven) system that is completely separate from any
GUI. Futhermore, check out Acitive Oberon for .NET. It is a language based
on the active object paradigm and it shows that the concept of being
event-driven need not be tied only to the GUI.
However, you can always have a list
of references to delegate objects to queue your job items and when your
code finishes its current processing it can pull the next delegate form the
list and execute its method(s).


I'm hoping to leverage the event-queuing already built into Windows.
Posting messages (delegates) is simply
adding the delegate to the list - to the head or to the tail depending on the priority you wants to give to the work item.


Good points, but I still wish to use the existing infrastructure for

events rather than reinvent the wheel. Too bad PostMessage() doesn't have a
pre-built dotnet wrapper.

What is the right way to use PostMessage to post a message of a user-defined object type?

B\rgds
100
"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:rtHEb.402123$Dw6.1250132@attbi_s02...
Hi 100,
Any other ideas? I'm not using Controls or Forms. Also, I want the message queued.
Thanks,
Mountain

"100" <10*@100.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi Mountain,
> Whar you are looking for is Control.BeginInvoke. When called for the
thread
> owning the control it works lamost like PostMessage with a slight
> difference. The difference is that with BeginInvoke the next thing that
is
> going to be executed from the thread will be the delegate you provide
to the
> BeginInvoke method. With post message your message will be queued
and will
> wait its time to come.
>
> HTH
> B\rgds
> 100
>
> "Mountain Bikn' Guy" <vc@attbi.com> wrote in message
> news:R2lEb.594304$Fm2.545394@attbi_s04...
> > I guess the answer is the same as every previous time it was asked

;) > >
>

http://groups.google.com/groups?hl=e...TF-8%26hl%3Den > >
> > However, that doesn't seem very satisfactory for C#.
> >
> > Is there a nice way to do this using delegates? What I want to do is queue
> > an event (with args derived from EventArgs) that my object will then > handle
> > when it finishes with it's current processing. Any other suggestions? > (BTW,
> > my objects are all normal classes, not Forms, Controls, etc.)
> >
> > Thanks,
> > Mountain
> > What is the best newsreader?
> >
> > "Mountain Bikn' Guy" <vc@attbi.com> wrote in message
> > news:yXkEb.582999$HS4.4336412@attbi_s01...
> > > What is the C# equivalent to calling PostMessage() in Win32 in order for
> > an
> > > object to queue a message to itself?
> > > Thanks
> > > Mountain
> > >
> > >
> >
> >
>
>



Nov 15 '05 #7

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

Similar topics

1
by: Markus von Ehr | last post by:
Hi, in a data acquisition program I have several threads, one thread grabbing images and another doing some processing. I'd like to make my own image class containing the image and additional...
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...
9
by: mateom | last post by:
Hello, I'm using Queue to send images from one thread to another, and some of the images are not appearing in the consumer thread....maybe 1 in 3 arrive. I've tried passing the image data in...
2
by: SA Trygubenko | last post by:
Dear All, Python 2.4 (#1, Mar 22 2005, 21:42:42) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Queue >>> q=Queue.Queue() >>> type(q.queue)...
13
by: Jonathan Amsterdam | last post by:
I think there's a slight design flaw in the Queue class that makes it hard to avoid nested monitor deadlock. The problem is that the mutex used by the Queue is not easy to change. You can then...
3
by: cypher543 | last post by:
My app uses a "queue" of commands which are run one at a time. I am using the subprocess module to execute the commands in the queue. However, processes always run at the same time. How can I make...
3
by: jrpfinch | last post by:
I have a script which is based on the following code. Unfortunately, it only works on Python 2.3 and not 2.5 because there is no esema or fsema attribute in the 2.5 Queue. I am hunting through...
11
by: Terry | last post by:
Hello! I'm trying to implement a message queue among threads using Queue. The message queue has two operations: PutMsg(id, msg) # this is simple, just combine the id and msg as one and put it...
1
by: psaffrey | last post by:
I'm trying to implement an application that will listen for requests, run them when they are present but also be able to add new requests even while it's running. I've tried to do this using the...
3
by: scriptlearner | last post by:
I am trying to put up a queue (through a logging thread) so that all worker threads can ask it to log messages. However, the problem I am facing is that, well, the logging thread itself is running...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.