Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using AopAlliance.Intercept;
|
---|
6 | using System.Threading;
|
---|
7 | using HeuristicLab.Hive.Server.LINQDataAccess;
|
---|
8 | using System.Transactions;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Hive.Server {
|
---|
11 | class ServiceCallInterception: IMethodInterceptor {
|
---|
12 | #region IMethodInterceptor Members
|
---|
13 |
|
---|
14 | public object Invoke(IMethodInvocation invocation) {
|
---|
15 | Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " + invocation.Method.Name);
|
---|
16 |
|
---|
17 | Object obj;
|
---|
18 |
|
---|
19 | // using (TransactionScope scope = new TransactionScope()) {
|
---|
20 | try {
|
---|
21 | obj = invocation.Proceed();
|
---|
22 | // scope.Complete();
|
---|
23 | } finally {
|
---|
24 | ContextFactory.Context.Dispose();
|
---|
25 | Console.WriteLine("setting old context null");
|
---|
26 | ContextFactory.Context = null;
|
---|
27 | Console.WriteLine("Disposing old Context");
|
---|
28 | }
|
---|
29 | // }
|
---|
30 | Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " + invocation.Method.Name);
|
---|
31 | return obj;
|
---|
32 | }
|
---|
33 |
|
---|
34 | #endregion
|
---|
35 | }
|
---|
36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.