diff options
author | John Hurliman | 2009-09-01 11:26:08 -0700 |
---|---|---|
committer | Diva Canto | 2009-09-03 12:27:23 -0700 |
commit | 584c1138361c6c5ed3ad18225760fb5f9e88093a (patch) | |
tree | ff25b4a645ff2f473119f0c04ead010b29b886e6 | |
parent | Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-584c1138361c6c5ed3ad18225760fb5f9e88093a.zip opensim-SC_OLD-584c1138361c6c5ed3ad18225760fb5f9e88093a.tar.gz opensim-SC_OLD-584c1138361c6c5ed3ad18225760fb5f9e88093a.tar.bz2 opensim-SC_OLD-584c1138361c6c5ed3ad18225760fb5f9e88093a.tar.xz |
Added Util.FireAndForget(), to replace leaking calls to Delegate.BeginInvoke()
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index bbb0ae2..58344f3 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1169,5 +1169,27 @@ namespace OpenSim.Framework | |||
1169 | 1169 | ||
1170 | return found.ToArray(); | 1170 | return found.ToArray(); |
1171 | } | 1171 | } |
1172 | |||
1173 | #region FireAndForget Threading Pattern | ||
1174 | |||
1175 | public static void FireAndForget(System.Threading.WaitCallback callback) | ||
1176 | { | ||
1177 | callback.BeginInvoke(null, EndFireAndForget, callback); | ||
1178 | } | ||
1179 | |||
1180 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) | ||
1181 | { | ||
1182 | callback.BeginInvoke(obj, EndFireAndForget, callback); | ||
1183 | } | ||
1184 | |||
1185 | private static void EndFireAndForget(IAsyncResult ar) | ||
1186 | { | ||
1187 | System.Threading.WaitCallback callback = (System.Threading.WaitCallback)ar.AsyncState; | ||
1188 | |||
1189 | callback.EndInvoke(ar); | ||
1190 | ar.AsyncWaitHandle.Close(); | ||
1191 | } | ||
1192 | |||
1193 | #endregion FireAndForget Threading Pattern | ||
1172 | } | 1194 | } |
1173 | } | 1195 | } |