@@ -1,4 +1,4 | |||
|
1 | <?xml version="1.0" encoding="utf-8"?> | |
|
1 | <?xml version="1.0" encoding="utf-8"?> | |
|
2 | 2 | <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
3 | 3 | <PropertyGroup> |
|
4 | 4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
@@ -35,6 +35,7 | |||
|
35 | 35 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
36 | 36 | <Compile Include="Promise.cs" /> |
|
37 | 37 | <Compile Include="AsyncPool.cs" /> |
|
38 | <Compile Include="Safe.cs" /> | |
|
38 | 39 | </ItemGroup> |
|
39 | 40 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
40 | 41 | <ItemGroup> |
@@ -7,11 +7,12 namespace Implab | |||
|
7 | 7 | { |
|
8 | 8 | public static class Safe |
|
9 | 9 | { |
|
10 |
public static void Dispose<T>(ref T obj) where T : |
|
|
10 | public static void Dispose<T>(ref T obj) where T : class | |
|
11 | 11 |
|
|
12 | if (obj != null) | |
|
12 | var disp = obj as IDisposable; | |
|
13 | if (disp != null) | |
|
13 | 14 | { |
|
14 |
|
|
|
15 | disp.Dispose(); | |
|
15 | 16 | obj = default(T); |
|
16 | 17 | } |
|
17 | 18 | } |
General Comments 0
You need to be logged in to leave comments.
Login now