[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

system messaging at Receiver end

RT

7/18/2004 6:25:00 AM

Dim ds1 As DataSet
Dim myMessage As Message
Try
myMessage = msgQ.Receive()
myMessage.Formatter = New XmlMessageFormatter(New Type() {GetType(ds)})
Catch ex As MessageQueueException
MessageBox.Show("ERROR: " + ex.Message, "MessageQueue Receive", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try

ds1 = CType(myMessage.Body, DataSet)
DataGrid1.DataSource = ds1




MsgBox("ok")


myMessage.Dispose()
ds1.Dispose()
------------------------------------
the above code using messaging (msmq) for reciever End.
i have keep in timer elapsed with interval of 1000
but the form hangs, i don't my application hang when i never recieve message.

Actually what i want is the application should popup me automatically when ever i recieve the message, how can i do it and my application should not crash...


1 Answer

Sunny

7/19/2004 2:56:00 PM

0

Hi,

your problem is that timer events are executed on a different thread, so
you can not update the form and form properties (as well as any control
on it) directly.

You have to use Control.Invoke instead.

Jon Skeet has very good article about threading, and there is a section
about windows forms as well:

http://www.yoda.arachsys.com/csharp/multithre...

Sunny




In article <335FA758-4C08-45FD-8462-DF3D7D21210F@microsoft.com>,
rt@discussions.microsoft.com says...
> Dim ds1 As DataSet
> Dim myMessage As Message
> Try
> myMessage = msgQ.Receive()
> myMessage.Formatter = New XmlMessageFormatter(New Type() {GetType(ds)})
> Catch ex As MessageQueueException
> MessageBox.Show("ERROR: " + ex.Message, "MessageQueue Receive", MessageBoxButtons.OK, MessageBoxIcon.Error)
> Exit Sub
> End Try
>
> ds1 = CType(myMessage.Body, DataSet)
> DataGrid1.DataSource = ds1
>
>
>
>
> MsgBox("ok")
>
>
> myMessage.Dispose()
> ds1.Dispose()
> ------------------------------------
> the above code using messaging (msmq) for reciever End.
> i have keep in timer elapsed with interval of 1000
> but the form hangs, i don't my application hang when i never recieve message.
>
> Actually what i want is the application should popup me automatically when ever i recieve the message, how can i do it and my application should not crash...
>
>
>