mono/mono-upnp — pull request #5 by sharpmonkey (2014-08-10 10:23:28+00:00)
Title: Dispose timeouts when disposing ServiceCache

When Client object ref is disposed before all ServiceCache services timeout callbacks have been processed exception is thrown:
System.NullReferenceException: Object reference not set to an instance of an object.
at Mono.Ssdp.Internal.ServiceCache.Remove(String usn, Boolean fromTimeout)
at Mono.Ssdp.Internal.ServiceCache.TimeoutHandler(Object state, TimeSpan& interval)
at Mono.Ssdp.Internal.TimeoutDispatcher.TimerThread(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

This commit addresses such scenarios with calling Dispose on timeouts when ServiceCache Dispose is called.