Пример #1
0
        private void duktape_Detached(object sender, EventArgs e)
        {
            PluginManager.Core.Invoke(new Action(async() =>
            {
                if (!expectDetach)
                {
                    await Task.Delay(1000);
                    if (!engineProcess.HasExited)
                    {
                        try
                        {
                            await Connect("localhost", 1208);
                            return;  // we're reconnected, don't detach.
                        }
                        catch (TimeoutException)
                        {
                            // if we time out on the reconnection attempt, go on and signal a
                            // detach to Sphere Studio.
                        }
                    }
                }

                focusTimer.Change(Timeout.Infinite, Timeout.Infinite);
                Detached?.Invoke(this, EventArgs.Empty);
                --plugin.Sessions;

                PluginManager.Core.Docking.Hide(Panes.Inspector);
                PluginManager.Core.Docking.Activate(Panes.Console);
                Panes.Console.Print("SSJ session has ended.");
            }), null);
        }
Пример #2
0
    protected virtual async ValueTask OnDetached(Channel <T> channel)
    {
        var taskCollector = ArrayBuffer <ValueTask> .Lease(true);

        try {
            Detached?.Invoke(channel, ref taskCollector);

            // The traversal direction doesn't matter, so let's traverse
            // it in reverse order to help the compiler to get rid of extra
            // bound checks.
            var tasks = taskCollector.Buffer;
            for (var i = taskCollector.Count - 1; i >= 0; i--)
            {
                var task = tasks[i];
                try {
                    await task.ConfigureAwait(false);
                }
                catch {
                    // Ignore: we want to invoke all handlers
                }
            }
        }
        finally {
            taskCollector.Release();
        }

        if (channel is IAsyncDisposable ad)
        {
            await ad.DisposeAsync().ConfigureAwait(false);
        }
        channel.Writer.TryComplete();
    }
Пример #3
0
 public void Detach()
 {
     Detaching?.Invoke();
     Instance = null;
     RootWidget.Unlink();
     Detached?.Invoke();
 }
Пример #4
0
 public void UnsetAll()
 {
     if (IsAttached)
     {
         isDummySet = false;
         successors.Clear();
         Detached?.Invoke(this, EventArgs.Empty);
     }
 }
Пример #5
0
        private void ProcessMessages()
        {
            while (true)
            {
                KiMessage message = KiMessage.Receive(tcp.Client);
                if (message == null)
                {
                    // if DMessage.Receive() returns null, detach.
                    tcp.Close();
                    Detached?.Invoke(this, EventArgs.Empty);
                    return;
                }
                else if (message[0].Tag == KiTag.NFY)
                {
                    switch ((KiNotify)(int)message[1])
                    {
                    case KiNotify.Detach:
                        tcp.Close();
                        Detached?.Invoke(this, EventArgs.Empty);
                        return;

                    case KiNotify.Log:
                        LogOp  type      = (LogOp)(int)message[2];
                        string debugText = (string)message[3];
                        string prefix    = type == LogOp.Trace ? "trace"
                                : "log";
                        Print?.Invoke(this, new TraceEventArgs(string.Format("{0}: {1}", prefix, debugText)));
                        break;

                    case KiNotify.Pause:
                        FileName   = (string)message[2];
                        LineNumber = (int)message[4];
                        Running    = false;
                        Status?.Invoke(this, EventArgs.Empty);
                        break;

                    case KiNotify.Resume:
                        Running = true;
                        Status?.Invoke(this, EventArgs.Empty);
                        break;

                    case KiNotify.Throw:
                        Throw?.Invoke(this, new ThrowEventArgs(
                                          (string)message[3], (string)message[4], (int)message[5],
                                          (int)message[2] != 0));
                        break;
                    }
                }
                else if (message[0].Tag == KiTag.REP || message[0].Tag == KiTag.ERR)
                {
                    lock (replyLock) {
                        KiMessage request = requests.Dequeue();
                        replies.Add(request, message);
                    }
                }
            }
        }
Пример #6
0
 /// <summary>
 /// Detaches this instance.
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         RenderCore.Detach();
         Disposer.RemoveAndDispose(ref bitmapCache);
         OnDetach();
         Detached?.Invoke(this, EventArgs.Empty);
     }
 }
Пример #7
0
        /// <summary>
        /// Requests that Duktape end the debug session.
        /// </summary>
        /// <returns></returns>
        public async Task Detach()
        {
            if (messenger == null)
            {
                return;
            }
            await DoRequest(DValueTag.REQ, Request.Detach);

            await Task.Run(() => messenger.Join());

            tcp.Client.Disconnect(true);
            Detached?.Invoke(this, EventArgs.Empty);
        }
Пример #8
0
 /// <summary>
 /// Detaches the element from the host. Override <see cref="OnDetach"/>
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         InvalidateSceneGraph();
         RenderCore.Detach();
         OnDetach();
         DisposeAndClear();
         renderTechnique = null;
         Detached?.Invoke(this, EventArgs.Empty);
     }
 }
        public async Task WaitNextFrameAsync()
        {
            nextFrame = false;
            DateTime timeout = DateTime.Now;

            while (!nextFrame)
            {
                if ((DateTime.Now - timeout).Seconds > 3)
                {
                    Detached?.Invoke(this, null);
                    break;
                }
            }
        }
Пример #10
0
        protected virtual async ValueTask OnDetachedAsync(Channel <T> channel)
        {
            var taskCollector = Collector <ValueTask> .New();

            try {
                Detached?.Invoke(channel, ref taskCollector);

                // The traversal direction doesn't matter, so let's traverse
                // it in reverse order to help the compiler to get rid of extra
                // bound checks.
                var tasks = taskCollector.Buffer;
                for (var i = taskCollector.Count - 1; i >= 0; i--)
                {
                    var task = tasks[i];
                    try {
                        await task.ConfigureAwait(false);
                    }
                    catch {
                        // Ignore: we want to invoke all handlers
                    }
                }
            }
            finally {
                taskCollector.Dispose();
            }

            switch (channel)
            {
            case IAsyncDisposable ad:
                await ad.DisposeAsync().ConfigureAwait(false);

                break;

            case IDisposable d:
                d.Dispose();
                break;

            default:
                for (var i = 0; i < 3; i++)
                {
                    if (channel.Writer.TryComplete())
                    {
                        break;
                    }
                    await Task.Delay(TimeSpan.FromSeconds(10)).ConfigureAwait(false);
                }
                break;
            }
        }
Пример #11
0
        public void Unset(INotifiable node, bool leaveDummy = false)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            if (!successors.Remove(node))
            {
                throw new InvalidOperationException("The specified node is not registered as the successor.");
            }
            if (!(isDummySet = leaveDummy))
            {
                Detached?.Invoke(this, EventArgs.Empty);
            }
        }
Пример #12
0
 public void Detach()
 {
     if (Target != null)
     {
         Target.DrawingSurface.PreviewMouseDown -= OnMouseDown;
         Target.DrawingSurface.PreviewMouseMove -= OnMouseMove;
         Target.DrawingSurface.PreviewMouseUp   -= OnMouseUp;
         Target.ZoomChanged          -= OnZoomChanged;
         Target.SelectedLayerChanged -= OnSelectedLayerChanged;
         Target.FrameChanged         -= OnFrameChanged;
         Target.ToolOptions.Children.Clear();
         Target.ExtensionPanel.Children.Clear();
         Detached.Invoke(this);
         Target = null;
     }
 }
Пример #13
0
 public void Detach()
 {
     if (state == PlayerState.Tethered)
     {
         AudioManager.instance.PlayEffect(detached);
         if (PlayerDetached != null)
         {
             PlayerDetached.Invoke();
         }
         state = PlayerState.Free;
         Vector3 relativePosition = CalculatePosToMoveTowards();
         movementAngle = Mathf.Tan(Mathf.Abs((posToMoveTowards.y - relativePosition.y) / (posToMoveTowards.x - relativePosition.x)));
         prevPos       = this.transform.position;
         AssignDirection(posToMoveTowards);
         linesLeft -= 1;
     }
 }
Пример #14
0
 protected virtual void OnViewDetached()
 {
     Detached?.Invoke();
 }
Пример #15
0
        private void ProcessMessages()
        {
            while (true)
            {
                DMessage message = DMessage.Receive(tcp.Client);
                if (message == null)
                {
                    // if DMessage.Receive() returns null, detach.
                    tcp.Close();
                    Detached?.Invoke(this, EventArgs.Empty);
                    return;
                }
                else if (message[0].Tag == DValueTag.NFY)
                {
                    switch ((Notify)(int)message[1])
                    {
                    case Notify.Status:
                        FileName   = (string)message[3];
                        LineNumber = (int)message[5];
                        Running    = (int)message[2] == 0;
                        Status?.Invoke(this, EventArgs.Empty);
                        break;

                    case Notify.Throw:
                        Throw?.Invoke(this, new ThrowEventArgs(
                                          (string)message[3], (string)message[4], (int)message[5],
                                          (int)message[2] != 0));
                        break;

                    case Notify.Detaching:
                        tcp.Close();
                        Detached?.Invoke(this, EventArgs.Empty);
                        return;

                    case Notify.AppNotify:
                        switch ((AppNotify)(int)message[2])
                        {
                        case AppNotify.DebugPrint:
                            PrintType type      = (PrintType)(int)message[3];
                            string    debugText = (string)message[4];
                            string    prefix    = type == PrintType.Assert ? "ASSERT"
                                        : type == PrintType.Debug ? "debug"
                                        : type == PrintType.Error ? "ERROR"
                                        : type == PrintType.Info ? "info"
                                        : type == PrintType.Trace ? "trace"
                                        : type == PrintType.Warn ? "warn"
                                        : "log";
                            Print?.Invoke(this, new TraceEventArgs(string.Format("{0}: {1}", prefix, debugText)));
                            break;
                        }
                        break;
                    }
                }
                else if (message[0].Tag == DValueTag.REP || message[0].Tag == DValueTag.ERR)
                {
                    lock (replyLock) {
                        DMessage request = requests.Dequeue();
                        replies.Add(request, message);
                    }
                }
            }
        }
Пример #16
0
        public virtual void Detach()
        {
            Target = null;

            Detached?.Invoke(this, EventArgs.Empty);
        }
Пример #17
0
 /// <summary>Invokes <see cref="Detached"/> event.</summary>
 private void OnDetached()
 => Detached?.Invoke(this, EventArgs.Empty);
Пример #18
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnDetached
 ///
 /// <summary>
 /// ドライブまたはメディアが取り外された時に発生するイベントです。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnDetached(DeviceEventArgs e)
 => Detached?.Invoke(this, e);
 private void OnDetached(object sender, EventArgs e)
 {
     Detached?.Invoke(sender, e);
 }
Пример #20
0
 private void _device_Removed()
 {
     EndPoint = null;
     Detached?.Invoke(this, null);
 }
Пример #21
0
 public void OnDetached(CompositeObject owner, CompositeObjectProperty prop)
 {
     Detached?.Invoke(owner, prop);
 }
Пример #22
0
 private void RaiseDetached()
 {
     Detached?.Invoke(this, EventArgs.Empty);
 }
Пример #23
0
 private void _device_Detached(object sender, EventArgs e)
 {
     Detached?.Invoke(this, null);
 }
Пример #24
0
 ///////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Handles the notifications from the USB device manager of the
 /// removal of a USB device.
 /// </summary>
 /// <param name="usbDevice">Reference the the USB device that has been detached.</param>
 public void OnDetached(object sender, EventArgs e)
 {
     _isAttached = false;
     // Check if anyone has registered for the event.
     Detached?.Invoke(sender, e);
 }