events-c#-urgent

  • Thread starter Thread starter reiks
  • Start date Start date
R

reiks

Can we post events in C#?

My requirement is that I call an event in a function,
but the event should execute at the end of the function,
after all the lines of code before the event gets called
and all the lines of code after the event are executed.

does .net supports this queuing of events?
 
To be honest, I didn't completely get what you are trying to accomplish, but
I think you should look and asynchronous calls and asynchronous delegates
(additional keywords: BeginInvoke, EndInvoke).
 
Hi Dmitry,

I think he is trying to set which events will be fired at the end of his
method (and not immediately).
As I understand it is like a transaction - if the method succeeds the events
will be fired otherwise not.
In that case the answer would be: no.
--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

Dmitriy Lapshin said:
To be honest, I didn't completely get what you are trying to accomplish, but
I think you should look and asynchronous calls and asynchronous delegates
(additional keywords: BeginInvoke, EndInvoke).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

reiks said:
Can we post events in C#?

My requirement is that I call an event in a function,
but the event should execute at the end of the function,
after all the lines of code before the event gets called
and all the lines of code after the event are executed.

does .net supports this queuing of events?
 
Hi Miha,

What about a pseudo-code like this:

bool wasError = false;

try
{
// Do some useful work;
}
catch
{
wasError = true;
throw;
}
finally
{
if (!wasError)
{
MyEvent(some arguments...);
}
}

One could also accumulate information on events to be raised in a custom
queue and process the queue in the finally block of the pseudo-code given
above. This is not easy, but doable.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Miha Markic said:
Hi Dmitry,

I think he is trying to set which events will be fired at the end of his
method (and not immediately).
As I understand it is like a transaction - if the method succeeds the events
will be fired otherwise not.
In that case the answer would be: no.
--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

Dmitriy Lapshin said:
To be honest, I didn't completely get what you are trying to accomplish, but
I think you should look and asynchronous calls and asynchronous delegates
(additional keywords: BeginInvoke, EndInvoke).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

reiks said:
Can we post events in C#?

My requirement is that I call an event in a function,
but the event should execute at the end of the function,
after all the lines of code before the event gets called
and all the lines of code after the event are executed.

does .net supports this queuing of events?
 
Back
Top