public void Fire(string name, object value) { var key = new MethodKey(name, value.GetType()); foreach (var pair in _instanceDict) { if (!pair.Value.ContainsKey(key)) { continue; } foreach (var method in pair.Value[key]) { switch (method.Subscribe.ThreadMode) { case ThreadMode.Default: method.Method.Invoke(pair.Key, new[] { value }); break; case ThreadMode.Background: AsyncUtils.RunAsynchronious(() => { try { method.Method.Invoke(pair.Key, new[] { value }); } catch (TargetInvocationException e) { if (e.InnerException is TaskCanceledException) { return; } throw; } }); break; default: throw new NotImplementedException(); } } } }