private void FireUsingPortal(object sender, UsingPortalEventArgs eventArgs) { this._usingPortalPending.Set(); REPlugin.Instance.Debug.WriteObject(eventArgs); if (this.UsingPortal != null) { this.UsingPortal(sender, eventArgs); } // TODO : Test this out. Will it be a problem that this sleep will block all other // background actions while we are waiting? Might not be the best behavior for this use case. // May have to use BeginInvoke somewhere (or some other thread pool based async invoke) REPlugin.Instance.Dispatch.Background.QueueAction(() => { if (!this._usingPortalPending.WaitOne(UsingPortalTimeoutInMilliseconds)) { // Timed out trying to use the portal. // Need to get back on the game thread REPlugin.Instance.Dispatch.LegacyGameThread.QueueAction(() => { this.FireUsingPortalComplete(sender, new UsingPortalCompleteEventArgs(false)); }); } }); }
internal void WriteObject(UsingPortalEventArgs obj) { if (ActiveSettings.Instance.DebugLevel == DebugLevel.None) return; lock (this._writeLock) { using (StreamWriter stream = new StreamWriter(this._currentPath, true)) { this.LogRawMessage(this.FormatWithPrefix("UsingPortalEventArgs"), stream); this.LogRawMessage(string.Format(" PortalName = {0}", obj.PortalName), stream); this.LogRawMessage(string.Format(" PortalId = {0}", obj.PortalId), stream); //this.WriteCurrentStateStuff(stream, false); this.LogRawMessage("", stream); } } }