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

Is RaiseEvent Synchronous or Asynchronous in VB .Net ??

Al
Hi,

I believe that when an event is Raised is C#, it is performed synchronously, as a value is returned by the event handler, even if that value is NULL. However, as VB does not have the ability to receive a return value, I was wondering is the call was performed asynchronously, rather than blocking on a call for which it would not receive a response.

I was specifically thinking of the case of having a cient subscribing to the event in a server, and the server being present in a remote machine.

Al

Nov 20 '05 #1
3 6083

Raising an event calls the handlers synchronously, regardless of
language.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #2
* "=?Utf-8?B?QWw=?=" <Al@discussions.microsoft.com> scripsit:
I believe that when an event is Raised is C#, it is performed
synchronously, as a value is returned by the event handler, even if that
value is NULL. However, as VB does not have the ability to receive a
return value, I was wondering is the call was performed asynchronously,
rather than blocking on a call for which it would not receive a
response.


The 'RaiseEvent' statement is processed as a call to the 'Invoke' method
of the event's delegate. This is a synchronous operation.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Al,
In addition to the

Events in .NET any language are processed synchronously.

I believe because to be CLS compliant events do not return values, thus VB
does not allow a return value for an event. Also events by definition are
multicast, if the event returned a value how would each handler return its
value where there are more then one handler??

What I would do is follow the Event Pattern & define my event as a Sub with
Object & EventArgs parameters and make a custom EventArgs that has the
"return value" in it. (Similar to the
System.ComponentModel.CancelEventHandler)

Something like:

Public Class GetDataEventArgs
Inherits EventArgs

Private m_data As Integer

Public Property Data() As Integer
Get
Return m_data
End Get
Set(ByVal value As Integer)
m_data = value
End Set
End Property

End Class

Public Delegate Sub GetDataHandler(ByVal sender As Object, ByVal e As
GetDataEventArgs)

Public Class MyProcess

Public Event GetData As GetDataHandler

Protected Overridable Sub OnGetData(ByVal e As GetDataEventArgs)
RaiseEvent GetData(Me, e)
End Sub

Public Sub Process()
Dim e As New GetDataEventArgs
OnGetData(e)
If e.Data = 100 Then
' do something interesting
End If
End Sub

End Class

Hope this helps
Jay

"Al" <Al@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
Hi,

I believe that when an event is Raised is C#, it is performed synchronously, as a value is returned by the event handler, even if that
value is NULL. However, as VB does not have the ability to receive a return
value, I was wondering is the call was performed asynchronously, rather than
blocking on a call for which it would not receive a response.
I was specifically thinking of the case of having a cient subscribing to the event in a server, and the server being present in a remote machine.
Al

Nov 20 '05 #4

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

Similar topics

1
by: Noel | last post by:
Hi, I am a tad confused about if there are any benefits from using asynchronous vs synchronous network communication. As my example, I have been writing a dns lookup stack with a network...
1
by: Chris | last post by:
Hi. I have a ibrary I'm trying to use via javascript within IE. This library uses an asynchronous model where I call into a function and pass it a callback function as one of its arguments. My...
15
by: Javier Estrada | last post by:
Can someone explaing the difference between these exception models regarding the structured exception handling? The documentation is not clear. Some code would actually help. Thx
1
by: Alexander Kaplunov | last post by:
I have two different scenarios: 1. I have an application that calls a web service and passes an object. Web Service takes that object and does some stuff with it, which could take...
3
by: Pro1712 | last post by:
Hi, this may be a stupid question: How can I can call the DoWork-function of a BackgroundWorker synchronous? Or in other words: How can I extend the BackgroundWorker class with a function...
2
by: Gary Wessle | last post by:
Hi what is the difference between synchronous vs. asynchronous messages an object sends to another. google was not much of a friend and wikipedia did not come to the rescue. thanks
5
by: HugeBob | last post by:
Hi All, I've got a question about Asynchronous vs Synchronous mode with the XMLHttpRequest object. What are the ramifications of using one mode vs the other? If the script uses Asynchronous...
0
ammoos
by: ammoos | last post by:
hi friends pls help me.. i got an assignment which i feel very difficult to me.. i dont have more knowledge about multi-threading in .net... the assignment details is below.... pls help me... i...
4
by: kp7796 | last post by:
What is synchronous function? What is asynchronous function? Unsigned char a=0; Void function (void ){ Unsigned char Flag; Flag=0 If (a==1){ Flag=1; }
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: 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?
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
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...
0
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...
0
tracyyun
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...

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.