Asynchronous Method Invocation
2 posts • Page 1 of 1
Asynchronous Method Invocation
I'm new in AOP and perhaps I'm saying a nosense but I'd like to implement an attribute that executes one method Asynchronously and executes the callback at the end of te Asynchronous process.
For Example
....
[ASYNC(FinalMethod=Endrocess)]
private void DoSomeWork()
{
//Long Task...
}
private void EndProcess()
{
MessageBox.Show("Process Finished");
}
Any Idea?
For Example
....
[ASYNC(FinalMethod=Endrocess)]
private void DoSomeWork()
{
//Long Task...
}
private void EndProcess()
{
MessageBox.Show("Process Finished");
}
Any Idea?
- zwan
- Posts: 1
- Joined: Wed Jan 16, 2008 12:19 am
- Full Name: juan Antonio
Re: Asynchronous Method Invocation
Juan,
Using OnMethodInvocationAspect, it is possible to execute a long method inside a different thread (you surely want to run it outside the GUI thread), and display a message when it's done. Do not forget to 'serialize' the call to MessageBox to the GUI thread, however.
Actually, OnMethodInvocationAspect gives you a delegate to the method being invoked, then it's yours to do what you want -- and it's pretty much general .NET WinForms programming.
Gael
Using OnMethodInvocationAspect, it is possible to execute a long method inside a different thread (you surely want to run it outside the GUI thread), and display a message when it's done. Do not forget to 'serialize' the call to MessageBox to the GUI thread, however.
Actually, OnMethodInvocationAspect gives you a delegate to the method being invoked, then it's yours to do what you want -- and it's pretty much general .NET WinForms programming.
Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
got good support? consider donating to the project.
- gfraiteur
- Site Admin
- Posts: 608
- Joined: Tue Dec 18, 2007 3:09 pm
- Full Name: Gael Fraiteur
- Company: postsharp.org
2 posts • Page 1 of 1