Is there any performance overhead in using RaiseEvent in .net
I have a code which is similar to following.
Dim _startTick As Integer = Environment.TickCount
'Do some Task'
Dim duration As Integer = Environment.TickCount - _startTick
Logger.Debug("Time taken : {0}", duration)
RaiseEvent Datareceived()
Above code returns
Time Taken :1200
Time Taken :1400
But if remove RaiseEvent it returns
Time Taken :110
Time Taken :121
I am surprised that the raiseevent is called after the logging of time taken. How it effects total time taken.
I am working on Compact framework.
Update:
In the Eventhandler I had given a MsgBox. When I removed the message box it is now showing time taken as 110,121,etc i.e. less that 500 milliseconds. If I put the Msgbox back in eventhandler it shows 1200,1400,etc i.e. more that a second.
More surprised now.(Event is raised after the logging part)