protected void EventHandler(EventInfo e) { if (_IsCompleted) { return; } // Events that don't match are silently rejected. // FIXME: Is this actually horrible if (!TryExtractResult(e, out Result)) { return; } e.Consume(); _IsCompleted = true; Dispose(); if (Continuation != null) { Continuation(); } if (_Future != null) { _Future.SetResult(Result, null); } }
protected override IEnumerator <object> OnPreferencesChanged(Squared.Util.Event.EventInfo evt, string[] prefNames) { var oldPort = GetPref("ServerPort", 80); yield return(Preferences.GetAll().Bind(() => CurrentPrefs)); if (GetPref("ServerPort", 80) != oldPort) { yield return(ResetListener()); } }
protected abstract bool TryExtractResult(EventInfo e, out T result);