-
Notifications
You must be signed in to change notification settings - Fork 485
Closed
Labels
Description
Hello,
I wanted to create an "async shell" for methods to run asynchronously.
I created an AsyncInterceptor which look like this:
public void Intercept(IInvocation invocation)
{
//Methods starts with add_ or remove_ are registration and unregistration methods to the class's events.
//Those methods should be invoked synchronously
if (invocation.Method.Name.StartsWith("add_") || invocation.Method.Name.StartsWith("remove_"))
{
invocation.Proceed();
}
else
{
Task.Run(() => invocation.Proceed());
}
}Unfortunately, it didn't work. For some reason the interceptor was called much more than once.
By looking at AbstractInvocation I saw the Proceed method is not thread safe ( Mostly the usage of currentInterceptorIndex ).
I wonder if there is anyway to support this kind of behavior.
Thanks,
Reactions are currently unavailable