main
1using Castle.Core.Interceptor;
2using gorilla.commons.Utility;
3
4namespace momoney.service.infrastructure.threading
5{
6 public class RunOnBackgroundThreadInterceptor<CommandToExecute> : IInterceptor
7 where CommandToExecute : DisposableCommand
8 {
9 readonly IBackgroundThreadFactory thread_factory;
10
11 public RunOnBackgroundThreadInterceptor(IBackgroundThreadFactory thread_factory)
12 {
13 this.thread_factory = thread_factory;
14 }
15
16 public virtual void Intercept(IInvocation invocation)
17 {
18 using (thread_factory.create_for<CommandToExecute>())
19 {
20 invocation.Proceed();
21 }
22 }
23 }
24}