private static bool CanStart(TimeDelegate callback, ref int hashCode) { if (callback == null) { CantStartBecauseCallbackCannotBeNullException.ToLog(); return(false); } if (_synchronizationContext == null) { CantStartBecauseNullContextException.ToLog(); return(false); } if (_synchronizationContext != SynchronizationContext.Current) { CantStartBecauseNotStartedContextException.ToLog(); return(false); } var index = FindIndexBucket(callback); if (index > -1) { CantStartBecauseCallbackExistedException.ToLog(); return(false); } hashCode = callback.GetHashCode(); return(true); }
private static int FindIndexBucket(TimeDelegate callback) { var hashCode = callback.GetHashCode(); return(_buckets != null ? _buckets.FindIndex(t => t.HashCode == hashCode) : -1); }