private void DownloadUpdateCompleted(object sender, AsyncCompletedEventArgs e) { try { btnDownload.Enabled = true; prgbDownload.Visible = false; if (e.Cancelled) { return; } if (e.Error != null) { throw e.Error; } #if !PORTABLE if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { Shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath); } else { File.Delete(_appUpdate.CurrentUpdateInfo.UpdateFilePath); } #else MessageBox.Show(Language.strUpdatePortableDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OK, MessageBoxIcon.Information); #endif } catch (Exception ex) { Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateDownloadCompleteFailed, ex); } }
private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { try { btnDownload.Enabled = true; prgbDownload.Visible = false; if (e.Cancelled) { return; } if (e.Error != null) { throw (e.Error); } if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) { Shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath); return; } else { File.Delete(_appUpdate.CurrentUpdateInfo.UpdateFilePath); } } catch (Exception ex) { Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateDownloadCompleteFailed, ex); } }
public MessagePumpingObject(Func <T> Creator) { try { using var Created = new ManualResetEventSlim(false); var LocalDispatcher = default(Dispatcher?); var LocalInstance = default(T?); Thread = new Thread(() => { LocalDispatcher = Dispatcher.CurrentDispatcher; LocalInstance = Creator(); Created.Set(); Dispatcher.Run(); Shutdown?.Invoke(this, null); }); Thread.SetApartmentState(ApartmentState.STA); Thread.Name = $@"{nameof(MessagePumpingObject<T>)}"; Thread.Start(); Created.Wait(); this.Dispatcher = LocalDispatcher ?? throw new InvalidOperationException(); this.Instance = LocalInstance ?? throw new InvalidOperationException(); } catch { Thread?.Abort(); throw; } }
public MainWindow(IViewModel <MainWindowViewModel> model, LocLocalizer localizer, IMainWindowCoordinator mainWindowCoordinator, IDialogCoordinator coordinator, ProjectFileWorkspace workspace) : base(model) { _localizer = localizer; _mainWindowCoordinator = mainWindowCoordinator; _coordinator = coordinator; _workspace = workspace; InitializeComponent(); _mainWindowCoordinator.TitleChanged += () => Dispatcher.BeginInvoke(new Action(MainWindowCoordinatorOnTitleChanged)); _mainWindowCoordinator.IsBusyChanged += IsBusyChanged; Closing += OnClosing; Closed += async(sender, args) => { Shutdown?.Invoke(this, EventArgs.Empty); await Task.Delay(TimeSpan.FromSeconds(60)); Process.GetCurrentProcess().Kill(false); }; _coordinator.OnWindowConstructed += window => { SfSkinManager.SetVisualStyle(window, VisualStyles.Blend); }; }
public ShutdownDialogViewModel(IWindowManager windowManager, Shutdown mode, FtpContentViewModel ftp = null) { _windowManager = windowManager; _ftp = ftp; Mode = mode; Title = Resx.Shutdown; switch (mode) { case Shutdown.Both: _innerText = Resx.ShutdownDialogModeComputerAndXbox; break; case Shutdown.PC: _innerText = Resx.ShutdownDialogModeComputer; break; case Shutdown.Xbox: _innerText = Resx.ShutdownDialogModeXbox; break; default: throw new NotSupportedException("Invalid Shutdown mode: " + mode); } Caption = string.Format(Resx.ShutdownDialogCaption, _innerText); _counter = new TimeSpan(0, 0, 30); //TODO: config _timer = new Timer(TimerCallback, null, 0, 1000); }
/** * * @Title: shutdown * @Description: 关闭连接 * @param @throws IOException 参数 * @return void 返回类型 */ public void shutdownNow() { //如果客户端已经就绪并且激活(数据交互) if (clientSession.IsReady && clientSession.IsActive == true) { //发送多次关闭信息 Shutdown shutdown = new Shutdown(); shutdown.DestinationID = clientSession.Destination.SocketID; shutdown.SetSession(clientSession); try { clientEndpoint.DoSend(shutdown); // TimeUnit.MILLISECONDS.sleep(100); } catch (Exception e) { //logger.log(Level.SEVERE, "ERROR: Connection could not be stopped!", e); } clientSession.Socket.GetReceiver().Stop(); clientEndpoint.Stop(); //cd 添加 客户端一旦关闭就无效了,可以不移除,该对象关闭则不能使用了 clientEndpoint.RemoveSession(clientSession.SocketID); //关闭发送 clientSession.Socket.GetSender().Stop(); closed = true; } clientEndpoint.Stop(); }
public MainWindowViewModel(AutoCompleteBasedOnLucene autoCompleteText, IGetActionsForItem getActionsForItem, Logger log, UpdateManagerAdapter updateManager, IWindowManager windowManager, Shutdown shutdown) { _autoCompleteText = autoCompleteText; _getActionsForItem = getActionsForItem; _log = log; _updateManager = updateManager; _windowManager = windowManager; _shutdown = shutdown; _updateManager.UpdatesAvailable += (sender, args) => { { Status.SetMessage(this, "Update available, downloading"); _updateManager.PrepareUpdates(); } }; _updateManager.UpdatesReady += (sender, args) => { Status.SetMessage(this, "Update prepared, ready for install"); NotifyOfPropertyChange(() => UpdateVisible); NotifyOfPropertyChange(() => CanUpdate); }; _cancelationTokenSource = new CancellationTokenSource(); _argumentCancelationTokenSource = new CancellationTokenSource(); CommandOptions = new ListWithCurrentSelection <AutoCompletionResult.CommandResult>( new AutoCompletionResult.CommandResult(new TextItem(string.Empty), null)); ArgumentOptions = new ListWithCurrentSelection <string>(); Result = CommandOptions.Current; }
public static void EventLoop() { while (true) { IntPtr ptr = mpv_wait_event(MpvHandle, -1); mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); Debug.WriteLine(evt.event_id); if (MpvWindowHandle == IntPtr.Zero) { MpvWindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); } switch (evt.event_id) { case mpv_event_id.MPV_EVENT_SHUTDOWN: Shutdown?.Invoke(); AfterShutdown?.Invoke(); return; case mpv_event_id.MPV_EVENT_FILE_LOADED: FileLoaded?.Invoke(); break; case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART: PlaybackRestart?.Invoke(); var s = new Size(GetIntProp("dwidth"), GetIntProp("dheight")); if (VideoSize != s) { VideoSize = s; VideoSizeChanged?.Invoke(); } break; case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE: if (ClientMessage != null) { var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message)); ClientMessage?.Invoke(NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args)); } break; case mpv_event_id.MPV_EVENT_PROPERTY_CHANGE: var eventData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property)); if (eventData.format == mpv_format.MPV_FORMAT_FLAG) { foreach (var action in BoolPropChangeActions) { action.Invoke(Marshal.PtrToStructure <int>(eventData.data) == 1); } } break; } } }
/// <summary>Request a full snapshot to initialise the order book</summary> public async Task <JToken> QueryExchangeState(string market_name) { Shutdown.ThrowIfCancellationRequested(); var snapshot = await HubProxy.Invoke <string>("QueryExchangeState", market_name); return(Decode(snapshot)); }
private void btnAbort_Click(object sender, EventArgs e) { string abortParam = "-a"; Shutdown shutdown = new Shutdown(0, abortParam); shutdown.ShutdownAbort(); }
/// <summary> /// Raises the <see cref="PlayerSelectedWeapon"/> event. /// </summary> /// <param name="timestamp">Time at which <see cref="PlayerSelectedWeapon"/> event was fired.</param> protected virtual void OnShutdown(DateTime timestamp) { Shutdown.Fire(ServerEndPoint, new LogEventArgs() { Timestamp = timestamp }); }
public async Task Execute(IJobExecutionContext context) { // Run Shutdown in slow mode await Shutdown.CreateAndRun(false); Environment.Exit(0); }
public net_driver_t(string name, bool initialized, Init delegate_Init, Listen delegate_Listen, SearchForHosts delegate_SearchForHosts, Connect delegate_Connect, CheckNewConnections delegate_CheckNewConnections, QGetMessage delegate_QGetMessage, QSendMessage delegate_QSendMessage, SendUnreliableMessage delegate_SendUnreliableMessage, CanSendMessage delegate_CanSendMessage, CanSendUnreliableMessage delegate_CanSendUnreliableMessage, Close delegate_Close, Shutdown delegate_Shutdown) { this.name = name; this.initialized = initialized; this.delegate_Init = delegate_Init; this.delegate_Listen = delegate_Listen; this.delegate_SearchForHosts = delegate_SearchForHosts; this.delegate_Connect = delegate_Connect; this.delegate_CheckNewConnections = delegate_CheckNewConnections; this.delegate_QGetMessage = delegate_QGetMessage; this.delegate_QSendMessage = delegate_QSendMessage; this.delegate_SendUnreliableMessage = delegate_SendUnreliableMessage; this.delegate_CanSendMessage = delegate_CanSendMessage; this.delegate_CanSendUnreliableMessage = delegate_CanSendUnreliableMessage; this.delegate_Close = delegate_Close; this.delegate_Shutdown = delegate_Shutdown; }
public Task Handle(object request, CancellationToken token) { ShutdownRequested = true; Shutdown?.Invoke(ShutdownRequested); _shutdownSource.SetResult(true); // after all event sinks were notified return(Task.CompletedTask); }
private void AddCommandsToDic() { CreateNewFolder createNewFolder = new CreateNewFolder(); CreateNewFile createNewFile = new CreateNewFile(); LockPc lockPc = new LockPc(); Shutdown shutDown = new Shutdown(); SearchInPc searchInPc = new SearchInPc(); UnlockPc unlockPc = new UnlockPc(); SleepPc sleepPc = new SleepPc(); SleepLuna sleepLuna = new SleepLuna(); WakeUpLuna wakeUpLuna = new WakeUpLuna(); CreateClass createClass = new CreateClass(); DefineLanguage defineLanguage = new DefineLanguage(); DefineProjectName defineProjectName = new DefineProjectName(); DefineProjectPath defineProjectPath = new DefineProjectPath(); GoTo goTo = new GoTo(); WhereAmI whereAmI = new WhereAmI(); dic.Add(createNewFile.CommandName, createNewFile); dic.Add(createNewFolder.CommandName, createNewFolder); dic.Add(lockPc.CommandName, lockPc); dic.Add(shutDown.CommandName, shutDown); dic.Add(searchInPc.CommandName, searchInPc); dic.Add(unlockPc.CommandName, unlockPc); dic.Add(sleepPc.CommandName, sleepPc); dic.Add(sleepLuna.CommandName, sleepLuna); dic.Add(wakeUpLuna.CommandName, wakeUpLuna); dic.Add(createClass.CommandName, createClass); dic.Add(defineLanguage.CommandName, defineLanguage); dic.Add(defineProjectName.CommandName, defineProjectName); dic.Add(defineProjectPath.CommandName, defineProjectPath); dic.Add(goTo.CommandName, goTo); dic.Add(whereAmI.CommandName, whereAmI); }
public Task Handle() { ShutdownRequested = true; Shutdown?.Invoke(ShutdownRequested); shutdownSource.SetResult(true); // after all event sinks were notified return(Task.CompletedTask); }
public void Run() { GraphicsDeviceOptions options = new GraphicsDeviceOptions( debug: false, swapchainDepthFormat: PixelFormat.R16_UNorm, syncToVerticalBlank: true, resourceBindingModel: ResourceBindingModel.Improved, preferDepthRangeZeroToOne: true, preferStandardClipSpaceYDirection: true); #if DEBUG options.Debug = true; #endif // construct a graphics device using the default backend. _gd = VeldridStartup.CreateGraphicsDevice(_window, options); // to determine what the default backend is you can run: //VeldridStartup.GetPlatformDefaultBackend() // to specify a specific backend use: //_gd = VeldridStartup.CreateGraphicsDevice(_window, options, GraphicsBackend.Metal); _factory = new DisposeCollectorResourceFactory(_gd.ResourceFactory); GraphicsDeviceCreated?.Invoke(_gd, _factory, _gd.MainSwapchain); Stopwatch sw = Stopwatch.StartNew(); double previousElapsed = sw.Elapsed.TotalSeconds; while (IsWindowOpen()) { double newElapsed = sw.Elapsed.TotalSeconds; float deltaSeconds = (float)(newElapsed - previousElapsed); InputSnapshot inputSnapshot = _window.PumpEvents(); InputTracker.UpdateFrameInput(inputSnapshot); if (_window.Exists) { previousElapsed = newElapsed; if (_windowResized) { _windowResized = false; _gd.ResizeMainWindow((uint)_window.Width, (uint)_window.Height); Resized?.Invoke(); } Rendering?.Invoke(deltaSeconds); } } Shutdown?.Invoke(); _gd.WaitForIdle(); _factory.DisposeCollector.DisposeAll(); _gd.Dispose(); GraphicsDeviceDestroyed?.Invoke(); }
protected void SendShutdown() { Shutdown s = new Shutdown(); s.DestinationID = session.Destination.SocketID; s.SetSession(session); endpoint.DoSend(s); }
/// <summary> /// Handle Shutdown message. /// </summary> /// <param name="msg">The message to handle.</param> private void Handle(Shutdown msg) { if (_dmvActor != null) { Context.Stop(_dmvActor); } Context.Stop(Self); }
internal ShutdownEvent InvokeEvent(ShutdownEvent arg) { if (_api.ValidateEvent(arg)) { Shutdown?.Invoke(_api, arg); } return(arg); }
private void desktop_Exit(object sender, EventArgs e) { Desktop form = (Desktop)sender; Shutdown s = new Shutdown(); s.Show(); s.Closed += shutdown_Exit; s.quitForRestart = form.quitForRestart; }
public MainWindow(IViewModel <MainWindowViewModel> model, LocLocalizer localizer) : base(model) { LocLocalizer.Inst = localizer; InitializeComponent(); Closed += (sender, args) => Shutdown?.Invoke(this, EventArgs.Empty); }
public void Exit() { Global.TickManager.Remove(Pet); StopAll(); Shutdown?.Invoke(this, EventArgs.Empty); Checkers.Stop(); Pet.Gears.Clear(); Gear = null; }
private void buttonClose_Click(object sender, EventArgs e) { if (_isFatal) { Shutdown.Quit(); } Close(); }
static void Main(string[] args) { var IsSafeMode = GetSystemMetrics(SM_CLEANBOOT); bool safeModeActive = Convert.ToBoolean(IsSafeMode); if (safeModeActive) { ManagementObjectSearcher wmiData = new ManagementObjectSearcher(@"root\SecurityCenter2", "SELECT * FROM AntiVirusProduct"); ManagementObjectCollection data = wmiData.Get(); foreach (ManagementObject virusChecker in data) { var AvName = virusChecker["displayName"]; var xstate = virusChecker["productState"]; var f = Convert.ToInt32(xstate); var zz = f.ToString("X").PadLeft(6, '0'); var StatusOfAV = ""; var y = zz.Substring(2, 2); switch (y) { case "00": StatusOfAV = "OFF"; break; case "01": StatusOfAV = "Exipired"; break; case "10": StatusOfAV = "ON"; break; case "11": StatusOfAV = "Snoozed"; break; default: StatusOfAV = "Unknown"; break; } string text = String.Format("In SafeBoot Mode = {0} AVInstalled = {1} Status = {2} ", Convert.ToBoolean(IsSafeMode).ToString(), AvName.ToString(), StatusOfAV); System.IO.File.WriteAllText(@"C:\Users\Public\SafeBoot.txt", text); BcdStoreAccessor b = new BcdStoreAccessor(); b.RemoveSafeboot(); Shutdown.Restart(); } } //some stuff came from here //https://gallery.technet.microsoft.com/scriptcenter/Get-the-status-of-4b748f25 }
private void shutdown_Exit(object sender, EventArgs e) { Shutdown form = (Shutdown)sender; if (form.quitForRestart) { Program.quitForRestart = true; } Program.quit = true; }
protected override void OnStop() { try { Shutdown.Invoke(this, EventArgs.Empty); } catch (Exception e) { EventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
protected override void OnShutdown() { try { Shutdown?.Invoke(this, EventArgs.Empty); } catch (Exception e) { WriteEntry(ServiceName, $"{ServiceName} threw an exception: {e}", EventLogEntryType.Error); } }
void PerformShutdown(ref Port <Shutdown> port) { if (port == null) { return; } Shutdown shutdown = new Shutdown(); port.Post(shutdown); port = null; }
private void đĂNGXUẤTToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult dlr = MessageBox.Show("Bạn có chắc muốn đăng xuất?", "THÔNG BÁO", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (DialogResult.OK == dlr) { Shutdown.Play(); frmDangnhap f = new frmDangnhap(); f.Show(); this.Hide(); } }
Choice PerformShutdown(ref Port<Shutdown> port) { Shutdown shutdown = new Shutdown(); port.Post(shutdown); port = null; return Arbiter.Choice( shutdown.ResultPort, delegate(SuccessResult success) { }, delegate(Exception e) { LogError(e); } ); }
protected override void Execute(Component component) { LocateJoystick(); if (!isEnabled || destinationAddress == null) return; // request control and update the GUI to denote this if (!hasControl) { RequestControl requestControl = new RequestControl(); requestControl.SetDestination(destinationAddress); requestControl.SetSource(component.JausAddress); Transport.SendMessage(requestControl); // update the connection icon for the correct component to orange if (destinationAddress.getComponent() == 1) connectionDetails.direct = ConnectionOption.REQUESTING_CONTROL; if (destinationAddress.getComponent() == 2) connectionDetails.remote = ConnectionOption.REQUESTING_CONTROL; if (destinationAddress.getComponent() == 3) connectionDetails.ai = ConnectionOption.REQUESTING_CONTROL; _eventAggregator.GetEvent<ConnectionDetailsEvent>().Publish(connectionDetails); return; } // shut down all components, then resume the one that should be active (i.e. jank hax) if (!isReady) { // shut down all active components Shutdown shutdown = new Shutdown(); int subsys = CurrentDestinationAddress.SubsystemID; int node = CurrentDestinationAddress.getNode(); JausAddress newAddress = new JausAddress(subsys, node, 1); QueryStatus queryStatus = new QueryStatus(); if (componentOneActive) { shutdown.SetDestination(newAddress); Transport.SendMessage(shutdown); queryStatus.SetDestination(newAddress); queryStatus.SetSource(component.JausAddress); Transport.SendMessage(queryStatus); } if (componentTwoActive) { newAddress.setComponent(2); shutdown.SetDestination(newAddress); Transport.SendMessage(shutdown); queryStatus.SetDestination(newAddress); queryStatus.SetSource(component.JausAddress); Transport.SendMessage(queryStatus); } if (componentThreeActive) { newAddress.setComponent(3); shutdown.SetDestination(newAddress); Transport.SendMessage(shutdown); queryStatus = new QueryStatus(); queryStatus.SetDestination(newAddress); queryStatus.SetSource(component.JausAddress); Transport.SendMessage(queryStatus); } // force component to boot Resume resume = new Resume(); resume.SetDestination(destinationAddress); resume.SetSource(component.JausAddress); Transport.SendMessage(resume); // see if the component is ready queryStatus = new QueryStatus(); queryStatus.SetDestination(destinationAddress); queryStatus.SetSource(component.JausAddress); Transport.SendMessage(queryStatus); return; } // send a drive message SetLocalVector msg = new SetLocalVector(); msg.SetDestination(destinationAddress); msg.SetSource(component.JausAddress); // convert joystick degrees into radians // TODO: THIS IS INCORRECT msg.SetHeading(joystickQueryThread.XVelocity * (Math.PI / 180)); //adding 100 to fit into defined setLocalVector MAX_SPEED & MIN_SPEED msg.SetSpeed(joystickQueryThread.YVelocity + 100); Transport.SendMessage(msg); }
void PerformShutdown(ref Port<Shutdown> port) { if (port == null) return; Shutdown shutdown = new Shutdown(); port.Post(shutdown); port = null; }
public net_driver_t(string name, bool initialized, Init delegate_Init, Listen delegate_Listen, SearchForHosts delegate_SearchForHosts, Connect delegate_Connect, CheckNewConnections delegate_CheckNewConnections, QGetMessage delegate_QGetMessage, QSendMessage delegate_QSendMessage, SendUnreliableMessage delegate_SendUnreliableMessage, CanSendMessage delegate_CanSendMessage, CanSendUnreliableMessage delegate_CanSendUnreliableMessage, Close delegate_Close, Shutdown delegate_Shutdown) { this.name = name; this.initialized = initialized; this.delegate_Init = delegate_Init; this.delegate_Listen = delegate_Listen; this.delegate_SearchForHosts = delegate_SearchForHosts; this.delegate_Connect = delegate_Connect; this.delegate_CheckNewConnections = delegate_CheckNewConnections; this.delegate_QGetMessage = delegate_QGetMessage; this.delegate_QSendMessage = delegate_QSendMessage; this.delegate_SendUnreliableMessage = delegate_SendUnreliableMessage; this.delegate_CanSendMessage = delegate_CanSendMessage; this.delegate_CanSendUnreliableMessage = delegate_CanSendUnreliableMessage; this.delegate_Close = delegate_Close; this.delegate_Shutdown = delegate_Shutdown; }
public void OnDeactivate(object arg) { JausAddress targetAddress = GenerateCurrentAddress(); if (targetAddress == null) return; Shutdown shutdown = new Shutdown(); shutdown.SetSource(badgerControlSubsystem.LocalAddress); shutdown.SetDestination(targetAddress); Transport.SendMessage(shutdown); }
public object Any(Shutdown request) { Redis.Shutdown(); return new ShutdownResponse(); }