public override void OnStartPrint(PrintDocument document, PrintEventArgs e) { base.OnStartPrint(document, e); this.document = document; this.pageNumber = 1; if (SystemInformation.UserInteractive) { this.backgroundThread = new BackgroundThread(this); } try { this.underlyingController.OnStartPrint(document, e); } catch { if (this.backgroundThread != null) { this.backgroundThread.Stop(); } throw; } finally { if ((this.backgroundThread != null) && this.backgroundThread.canceled) { e.Cancel = true; } } }
/// <include file='doc\PrintControllerWithStatusDialog.uex' path='docs/doc[@for="PrintControllerWithStatusDialog.OnStartPrint"]/*' /> /// <internalonly/> /// <devdoc> /// <para> /// Implements StartPrint by delegating to the underlying controller. /// </para> /// </devdoc> public override void OnStartPrint(PrintDocument document, PrintEventArgs e) { base.OnStartPrint(document, e); this.document = document; pageNumber = 1; if (SystemInformation.UserInteractive) { backgroundThread = new BackgroundThread(this); // starts running & shows dialog automatically } // OnStartPrint does the security check... lots of // extra setup to make sure that we tear down // correctly... // try { underlyingController.OnStartPrint(document, e); } catch { if (backgroundThread != null) { backgroundThread.Stop(); } throw; } finally { if (backgroundThread != null && backgroundThread.canceled) { e.Cancel = true; } } }
public BackgroundParser(RazorEngineHost host, string fileName) { _main = new MainThreadState(fileName); _bg = new BackgroundThread(_main, host, fileName); _main.ResultsReady += (sender, args) => OnResultsReady(args); }
public void should_not_continue_execution_after_awaiting_a_send_in_the_MessageReceived_thread() { using (MessageId.PauseIdGeneration()) { var command = new FakeCommand(456); SetupPeersHandlingMessage <FakeCommand>(_peerUp); _bus.Start(); var task = _bus.Send(command); var commandCompleted = new MessageExecutionCompleted(MessageId.NextId(), 0, null); int backgroundThreadId = 0; BackgroundThread.Start(() => { backgroundThreadId = Thread.CurrentThread.ManagedThreadId; _transport.RaiseMessageReceived(commandCompleted.ToTransportMessage()); }); var getThreadIdTask = GetThreadIdAfterAwaitingCommandResult(task); getThreadIdTask.Result.ShouldNotEqual(backgroundThreadId); } }
public override void OnStartPrint(PrintDocument document, PrintEventArgs e) { base.OnStartPrint(document, e); this.document = document; pageNumber = 1; if (SystemInformation.UserInteractive) { backgroundThread = new BackgroundThread(this); // starts running & shows dialog automatically } // OnStartPrint does the security check... lots of // extra setup to make sure that we tear down // correctly... // try { underlyingController.OnStartPrint(document, e); } catch { if (backgroundThread != null) { backgroundThread.Stop(); } throw; } finally { if (backgroundThread != null && backgroundThread.canceled) { e.Cancel = true; } } }
public InstanceManager(MainWindow mainWindow) { this.userlogin = new UserLogin(this); this.mainWindow = mainWindow; this.backgroundthread = new BackgroundThread(this); this.uihelp = new UIHelp(this); this.action = new ACTION(this); this.configManager = new ConfigManager(this); this.asset_textes = new Programe.TextRes.Asset_Textes(this); this.catchdatasummery = new CatchDataSummery(this); this.userdatasummery = new UserDataSummery(this); this.friend = new Friend(this); this.battleloop_n = new BattleLoop_Normal(this); this.battleloop_a = new BattleLoop_Activity(this); this.battleloop_s = new BattleLoop_Simulation(this); //4个后勤任务 for (int x = 0; x < 4; x++) { Operation_Act_Info auto_operation_act = new Operation_Act_Info(); Dic_auto_operation_act.Add(Dic_auto_operation_act.Count, auto_operation_act); } //练级任务 new_User_Normal_MissionInfo nunm = new new_User_Normal_MissionInfo(BattleLoop_AN_Teams, 0); dic_userbattletaskinfo.Add(dic_userbattletaskinfo.Count, nunm); for (int x = 0; x < 2; x++) { EquipBuilt eb = new EquipBuilt(); this.list_equipBuilt.Add(eb); } this.auto_summery = new Auto_Summery(this); this.battle_loop = new BattleLoop(this); }
static Log() { TrinityC.Init(); try { TrinityConfig.LoadTrinityConfig(); } catch { Log.WriteLine(LogLevel.Error, "Failure to load config file, falling back to default log behavior"); } string unitTestAssemblyName = "Microsoft.VisualStudio.QualityTools.UnitTestFramework"; bool isInUnitTest = AssemblyUtility.AnyAssembly(a => a.FullName.StartsWith(unitTestAssemblyName, StringComparison.Ordinal)); if (isInUnitTest) { WriteLine(LogLevel.Info, "UnitTestFramework detected. Enabling echo callback."); var LogFilename = Path.Combine(TrinityConfig.LogDirectory, "trinity-[" + DateTime.Now.ToStringForFilename() + "].log"); new Thread(_unitTestLogEchoThread).Start(LogFilename); } BackgroundThread.AddBackgroundTask(new BackgroundTask(CollectLogEntries, c_LogEntryCollectorIdleInterval)); }
/// <summary> /// Initializes Graph Engine. /// This method will be automatically called /// when the static constructor of `Global` /// is triggered. However, when the Graph Engine /// is uninitialized, one would have to manually /// call this again before using the local memory storage. /// </summary> public static void Initialize() { lock (s_storage_init_lock) { if (s_master_init_flag) { return; } _LoadGraphEngineExtensions(); _ScanForTSLStorageExtension(); _ScanForMemoryCloudExtension(); _ScanForStartupTasks(); s_master_init_flag = true; BackgroundThread.Start(); } try { Initialized(); } catch { //TODO log } }
internal RemoteStorage(AvailabilityGroup trinityServer, int connPerServer, MemoryCloud mc, int serverId, bool nonblocking) { this.memory_cloud = mc; this.MyServerId = serverId; var connect_async_task = Task.Factory.StartNew(() => { for (int k = 0; k < connPerServer; k++) // make different server connections interleaved { for (int i = 0; i < trinityServer.Instances.Count; i++) { Connect(trinityServer.Instances[i]); } } BackgroundThread.AddBackgroundTask(new BackgroundTask(Heartbeat, TrinityConfig.HeartbeatInterval)); mc.ReportServerConnectedEvent(serverId); }); if (!nonblocking) { try { connect_async_task.Wait(); } catch (AggregateException ex) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); } } }
internal StatusDialog(BackgroundThread backgroundThread, string dialogTitle) { InitializeComponent(); this.backgroundThread = backgroundThread; this.Text = dialogTitle; this.MinimumSize = Size; }
static Index() { BackgroundIndexUpdater(); BackgroundThread.AddBackgroundTask(new BackgroundTask(BackgroundIndexUpdater, s_BackgroundIndexUpdateInterval)); }
static void Main(string[] args) { BackgroundThread bt = new BackgroundThread(plainOldWorkerFunction, plainOldCallbackFunction); bt.Start(1234); }
/// <summary> /// Initializes a new instance of the AddressBookItemBackgroundThreadContext class /// </summary> /// <param name="thread"></param> /// <param name="item"></param> public AddressBookItemBackgroundThreadContext(BackgroundThread thread, AddressBookItem item) { _thread = thread; _item = item; }
private void StartReceptionThread() { _receptionThread = BackgroundThread.Start(PendingReceivesDispatcher); }
public static SimpleCoroutineAwaiter GetAwaiter(this BackgroundThread instruction) { return(GetAwaiterReturnVoid(instruction)); }
/// <summary> /// Shows progress dialog</summary> public void Show() { if (IsDialogVisible) return; if (m_backgroundThread == null) m_backgroundThread = new BackgroundThread(this); m_backgroundThread.UpdateLabel(); if (m_isCanceled) Close(); }
/// <summary>Initializes a new instance of the MainViewModel class.</summary> public MainViewModel() : base() { #if ENGLISH _dyTranslations.Add("AesKey", "256-bit AES key"); _dyTranslations.Add("AuthenticationKey", "authentication key"); _dyTranslations.Add("BitsText", "bits"); _dyTranslations.Add("Blocks", "blocks"); _dyTranslations.Add("BlockSize", "block size"); _dyTranslations.Add("Cancel", "cancel"); _dyTranslations.Add("CancelCreation", "cancel creation"); _dyTranslations.Add("CapacityInformation", "capacity up to {0:f1} % of the size of drive {1:s}"); _dyTranslations.Add("Close", "close"); _dyTranslations.Add("ComingSoon", "coming soon"); _dyTranslations.Add("Compare", "compare"); _dyTranslations.Add("CompareAgain", "compare again"); _dyTranslations.Add("CopiedToDestination", "copied to the destination directory"); _dyTranslations.Add("CopiedToSource", "copied to the source directory"); _dyTranslations.Add("Create", "create"); _dyTranslations.Add("CreatingNewKey", "Creating new key..."); _dyTranslations.Add("Deleted", "deleted"); _dyTranslations.Add("DestinationDateText", "destination date"); _dyTranslations.Add("DestinationDirectoryMissing", "The destination directory does not exist."); _dyTranslations.Add("DestinationDirectoryText", "destination directory"); _dyTranslations.Add("DestinationFile", "destination file"); _dyTranslations.Add("DestinationNewer", "destination newer"); _dyTranslations.Add("DestinationOnly", "destination only"); _dyTranslations.Add("DestinationSizeText", "destination size"); _dyTranslations.Add("DriveText", "drive"); _dyTranslations.Add("EmptyDriveName", "not saved"); _dyTranslations.Add("ErrorDirectoriesIdentical", "Identical or nested directories cannot be synchronized."); _dyTranslations.Add("ErrorFilesIdentical", "Identical files cannot be synchronized."); _dyTranslations.Add("ErrorMessageText", "error message"); _dyTranslations.Add("Export", "export"); _dyTranslations.Add("Failure", "failure"); _dyTranslations.Add("FileNotFound", "File »{0:s}« was not found."); _dyTranslations.Add("FinishCompare", "Comparison of the directories was finished."); _dyTranslations.Add("FinishFillKey", "Creation of a key was finished."); _dyTranslations.Add("FormatText", "format"); _dyTranslations.Add("FoundAuthenticationKey", "The name of the authentication key is »{0:s}«."); _dyTranslations.Add("FoundPrivateKey", "The name of the private key is »{0:s}«."); _dyTranslations.Add("FoundSymmetricKey", "The name of the AES key is »{0:s}«."); _dyTranslations.Add("Identical", "identical"); _dyTranslations.Add("Iterations", "iterations"); _dyTranslations.Add("KeyFormatPassword", "password"); _dyTranslations.Add("KeyFormatPrivate", "private"); _dyTranslations.Add("KeyFormatPublic", "public"); _dyTranslations.Add("KeyNumerals0", "value (hidden)"); _dyTranslations.Add("KeyNumerals2", "value (binary)"); _dyTranslations.Add("KeyNumerals10", "value (decimal)"); _dyTranslations.Add("KeyNumerals16", "value (hexadecimal)"); _dyTranslations.Add("KeyNumerals64", "value (Base64)"); _dyTranslations.Add("KeyInvalid", "The value for the 256-bit key is invalid."); _dyTranslations.Add("KeyNameText", "key name"); _dyTranslations.Add("KeyParameterSymmetric", "symmetric key"); _dyTranslations.Add("Keys", "keys"); _dyTranslations.Add("KeyTextPublic", "public"); _dyTranslations.Add("KeyTooLong", "The value for the 256-bit key is too long."); _dyTranslations.Add("KeyTooShort", "The value for the 256-bit key is too short."); _dyTranslations.Add("KeyTypeInvalid", "invalid"); _dyTranslations.Add("KeyTypeSymmetric", "symmetric"); _dyTranslations.Add("KeyTypeSymmetric256Bit", "symmetric, 256 bits"); _dyTranslations.Add("MaximumBlockCount", "max. block count (levels)"); _dyTranslations.Add("Messages", "messages"); _dyTranslations.Add("MessageText", "message"); _dyTranslations.Add("ModeNoDelete", "no delete"); _dyTranslations.Add("ModeTwoWay", "two-way"); _dyTranslations.Add("ModeWithDelete", "with delete"); _dyTranslations.Add("NewKey", "new key"); _dyTranslations.Add("NoAuthenticationKey", "No authentication key was found to match these data."); _dyTranslations.Add("NoSymmetricKey", "No symmetric key was found to match these data."); _dyTranslations.Add("OnDrive", "save on drive"); _dyTranslations.Add("PleaseCheck", "please check"); _dyTranslations.Add("ProgrammingError", "A programming error occurred. I am sorry, this should not have happened."); _dyTranslations.Add("ProgramVersion", "Program version " + sProgramVersion + " of 26/12/2020 is ready."); _dyTranslations.Add("Progress", "progress"); _dyTranslations.Add("ReadDrivesAndKeys", "re-read drives"); _dyTranslations.Add("RelativePathText", "relative path"); _dyTranslations.Add("ReplacedFromSource", "replaced with the older version from the source directory"); _dyTranslations.Add("Reserve", "reserve"); _dyTranslations.Add("Save", "save"); _dyTranslations.Add("Select", "select"); _dyTranslations.Add("SelectDestinationDirectory", "select destination directory"); _dyTranslations.Add("SelectDestinationFile", "select destination file"); _dyTranslations.Add("SelectSourceDirectory", "select source directory"); _dyTranslations.Add("SelectSourceFile", "select source file"); _dyTranslations.Add("SelectTemporaryDirectory", "select temporary directory"); _dyTranslations.Add("Size", "size"); _dyTranslations.Add("Skipped", "skipped"); _dyTranslations.Add("SourceDateText", "source date"); _dyTranslations.Add("SourceDirectoryMissing", "The source directory does not exist."); _dyTranslations.Add("SourceDirectoryText", "source directory"); _dyTranslations.Add("SourceFile", "source file"); _dyTranslations.Add("SourceFileMissing", "The source file does not exist."); _dyTranslations.Add("SourceSizeText", "source size"); _dyTranslations.Add("SourceNewer", "source newer"); _dyTranslations.Add("SourceOnly", "source only"); _dyTranslations.Add("StartCompare", "Comparison of the directories was started."); _dyTranslations.Add("StartFillKey", "Creation of a key was started."); _dyTranslations.Add("Swap", "swap"); _dyTranslations.Add("Synchronize", "synchronize"); _dyTranslations.Add("Task", "task"); _dyTranslations.Add("TaskNameText", "task name"); _dyTranslations.Add("TemporaryDirectoryText", "temporary directory for larger files"); _dyTranslations.Add("TimeText", "time"); _dyTranslations.Add("TypeText", "type"); _dyTranslations.Add("UnspecifiedError", "A relatively rare error occurred. This is why there is no more information."); _dyTranslations.Add("UseWorkingMemory", "use working memory up to"); _dyTranslations.Add("WillBe", "will be "); _dyTranslations.Add("WillBeSkipped", "will be skipped"); _dyTranslations.Add("WindowTitle", "File synchronization and mirrored backups"); _dyTranslations.Add("WrongFileFormat", "File »{0:s}« has a wrong format and could not be read."); #elif DEUTSCH _dyTranslations.Add("AesKey", "256-Bit AES-Schlüssel"); _dyTranslations.Add("AuthenticationKey", "Authentifizierungs-Schlüssel"); _dyTranslations.Add("BitsText", "Bit"); _dyTranslations.Add("Blocks", "Blöcke"); _dyTranslations.Add("BlockSize", "Blockgröße"); _dyTranslations.Add("Cancel", "abbrechen"); _dyTranslations.Add("CancelCreation", "Erzeugung abbrechen"); _dyTranslations.Add("CapacityInformation", "Kapazität bis zu {0:f1} % der Größe von Laufwerk {1:s}"); _dyTranslations.Add("Close", "schließen"); _dyTranslations.Add("ComingSoon", "folgt demnächst"); _dyTranslations.Add("Compare", "vergleichen"); _dyTranslations.Add("CompareAgain", "neu vergleichen"); _dyTranslations.Add("CopiedToDestination", "in das Zielverzeichnis kopiert"); _dyTranslations.Add("CopiedToSource", "in das Quellverzeichnis kopiert"); _dyTranslations.Add("Create", "erzeugen"); _dyTranslations.Add("CreatingNewKey", "Erzeuge neuen Schlüssel..."); _dyTranslations.Add("Deleted", "gelöscht"); _dyTranslations.Add("DestinationDateText", "Datum Ziel"); _dyTranslations.Add("DestinationDirectoryMissing", "Das Zielvereichnis existiert nicht."); _dyTranslations.Add("DestinationDirectoryText", "Zielverzeichnis"); _dyTranslations.Add("DestinationFile", "Zieldatei"); _dyTranslations.Add("DestinationNewer", "neueres Ziel"); _dyTranslations.Add("DestinationOnly", "nur Ziel"); _dyTranslations.Add("DestinationSizeText", "Größe Ziel"); _dyTranslations.Add("DriveText", "Laufwerk"); _dyTranslations.Add("EmptyDriveName", "ungespeichert"); _dyTranslations.Add("ErrorDirectoriesIdentical", "Identische oder in einander enthaltene Verzeichnisse können nicht synchronisiert werden."); _dyTranslations.Add("ErrorFilesIdentical", "Identische Dateien können nicht synchronisiert werden."); _dyTranslations.Add("ErrorMessageText", "Fehlernachricht"); _dyTranslations.Add("ErrorWorkingMemoryLimit", "Das Verschlüsseln mehrerer Gigabyte an Daten ist (noch) nicht möglich."); _dyTranslations.Add("Export", "exportieren"); _dyTranslations.Add("Failure", "fehlerhaft"); _dyTranslations.Add("FileNotFound", "Die Datei »{0:s}« wurde nicht gefunden."); _dyTranslations.Add("FinishCompare", "Der Vergleich der Verzeichnisse wurde beendet."); _dyTranslations.Add("FinishFillKey", "Das Erzeugen eines Schlüssels wurde beendet."); _dyTranslations.Add("FormatText", "Format"); _dyTranslations.Add("FoundAuthenticationKey", "Der Name des Authentifizierungs-Schlüssels ist »{0:s}«."); _dyTranslations.Add("FoundPrivateKey", "Der Name des privaten Schlüssels ist »{0:s}«."); _dyTranslations.Add("FoundSymmetricKey", "Der Name des AES-Schlüssels ist »{0:s}«."); _dyTranslations.Add("Identical", "identisch"); _dyTranslations.Add("Iterations", "Durchläufe"); _dyTranslations.Add("KeyFormatPassword", "Passwort"); _dyTranslations.Add("KeyFormatPrivate", "privat"); _dyTranslations.Add("KeyFormatPublic", "öffentlich"); _dyTranslations.Add("KeyNumerals0", "Wert (verborgen)"); _dyTranslations.Add("KeyNumerals2", "Wert (binär)"); _dyTranslations.Add("KeyNumerals10", "Wert (dezimal)"); _dyTranslations.Add("KeyNumerals16", "Wert (hexadezimal)"); _dyTranslations.Add("KeyNumerals64", "Wert (Base64)"); _dyTranslations.Add("KeyInvalid", "Der Wert für den 256-Bit-Schlüssel ist ungültig."); _dyTranslations.Add("KeyNameText", "Schlüsselname"); _dyTranslations.Add("KeyParameterSymmetric", "symmetrischer Schlüssel"); _dyTranslations.Add("Keys", "Schlüssel"); _dyTranslations.Add("KeyTextPublic", "öffentlich"); _dyTranslations.Add("KeyTooLong", "Der Wert für den 256-Bit-Schlüssel ist zu lang."); _dyTranslations.Add("KeyTooShort", "Der Wert für den 256-Bit-Schlüssel ist zu kurz."); _dyTranslations.Add("KeyTypeInvalid", "ungültig"); _dyTranslations.Add("KeyTypeSymmetric", "symmetrisch"); _dyTranslations.Add("KeyTypeSymmetric256Bit", "symmetrisch, 256 Bit"); _dyTranslations.Add("MaximumBlockCount", "max. Blockzahl (Ebenen)"); _dyTranslations.Add("Messages", "Nachrichten"); _dyTranslations.Add("MessageText", "Nachricht"); _dyTranslations.Add("ModeNoDelete", "kein Löschen"); _dyTranslations.Add("ModeTwoWay", "gegenseitig"); _dyTranslations.Add("ModeWithDelete", "mit Löschen"); _dyTranslations.Add("NewKey", "neuen Schlüssel"); _dyTranslations.Add("NoAuthenticationKey", "Zu diesen Daten wurde kein Authentifizierungs-Schlüssel gefunden."); _dyTranslations.Add("NoSymmetricKey", "Zu diesen Daten wurde kein symmetrischer Schlüssel gefunden."); _dyTranslations.Add("OnDrive", "auf Laufwerk"); _dyTranslations.Add("PleaseCheck", "bitte überprüfen"); _dyTranslations.Add("ProgrammingError", "Ein Programmierfehler ist aufgetreten. Entschuldigung, das hätte nicht passieren dürfen."); _dyTranslations.Add("ProgramVersion", "Die Programmversion " + sProgramVersion + " vom 26.12.2020 ist bereit."); _dyTranslations.Add("Progress", "Fortschritt"); _dyTranslations.Add("ReadDrivesAndKeys", "Laufwerke neu lesen"); _dyTranslations.Add("RelativePathText", "Relativer Pfad"); _dyTranslations.Add("ReplacedFromSource", "durch die ältere Version aus dem Quellverzeichnis ersetzt"); _dyTranslations.Add("Reserve", "reserviere"); _dyTranslations.Add("Save", "speichern"); _dyTranslations.Add("Select", "auswählen"); _dyTranslations.Add("SelectDestinationDirectory", "Zielverzeichnis wählen"); _dyTranslations.Add("SelectDestinationFile", "Zieldatei wählen"); _dyTranslations.Add("SelectSourceDirectory", "Quellverzeichnis wählen"); _dyTranslations.Add("SelectSourceFile", "Quelldatei wählen"); _dyTranslations.Add("SelectTemporaryDirectory", "Temporäres Verzeichnis wählen"); _dyTranslations.Add("Size", "Größe"); _dyTranslations.Add("Skipped", "übersprungen"); _dyTranslations.Add("SourceDateText", "Datum Quelle"); _dyTranslations.Add("SourceDirectoryMissing", "Das Quellvereichnis existiert nicht."); _dyTranslations.Add("SourceDirectoryText", "Quellverzeichnis"); _dyTranslations.Add("SourceFile", "Quelldatei"); _dyTranslations.Add("SourceFileMissing", "Die Quelldatei existiert nicht."); _dyTranslations.Add("SourceSizeText", "Größe Quelle"); _dyTranslations.Add("SourceNewer", "neuere Quelle"); _dyTranslations.Add("SourceOnly", "nur Quelle"); _dyTranslations.Add("StartCompare", "Der Vergleich der Verzeichnisse wurde gestartet."); _dyTranslations.Add("StartFillKey", "Das Erzeugen eines Schlüssels wurde gestartet."); _dyTranslations.Add("Swap", "tauschen"); _dyTranslations.Add("Synchronize", "synchronisieren"); _dyTranslations.Add("Task", "Aufgabe"); _dyTranslations.Add("TaskNameText", "Aufgabenname"); _dyTranslations.Add("TemporaryDirectoryText", "temporäres Verzeichnis für größere Dateien"); _dyTranslations.Add("TimeText", "Zeit"); _dyTranslations.Add("TypeText", "Typ"); _dyTranslations.Add("UnspecifiedError", "Ein relativ seltener Fehler ist aufgeteten. Genaueres ist deshalb nicht bekannt."); _dyTranslations.Add("UseWorkingMemory", "Arbeitsspeicher nutzen bis"); _dyTranslations.Add("WillBe", "werden "); _dyTranslations.Add("WillBeSkipped", "werden übersprungen"); _dyTranslations.Add("WindowTitle", "Dateisynchronisierung und gespiegelte Sicherungskopien"); _dyTranslations.Add("WrongFileFormat", "Die Datei »{0:s}« hat ein falsches Format und kann nicht gelesen werden."); #endif _dyTranslations.Add("HiddenKey", "●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●"); _sBackgroundStatus = _sDestinationDirectory = _sSourceDirectory = _sTaskName = string.Empty; _eBackgroundTask = BackgroundMessage.nType.Stop; _eSynchronizationMode = PairOfFiles.nSynchronizationMode.WithDelete; _ltDrives = new List <Drive>(); _ltPairs = new List <PairOfFiles>(); _blPairs = new BindingList <PairOfFiles>(); _Cryptography = null; _DestinationDrive = new Drive(_Cryptography, false); _SourceDrive = new Drive(_Cryptography, true); _BackgroundThread = new BackgroundThread(_Cryptography); _eMenuTab = nMenuTab.Task; _eCaseTab = PairOfFiles.nComparison.SourceOnly; _aiPairsCount = new int[(int)PairOfFiles.nComparison.Error + 1]; for (int i = 0; i < _aiPairsCount.Length; i++) { _aiPairsCount[i] = 0; } _aiPairsOrder = new int[(int)PairOfFiles.nComparison.Error + 1]; _aiPairsOrder[0] = 3; _aiPairsOrder[1] = 5; _aiPairsOrder[2] = 4; _aiPairsOrder[3] = 2; _aiPairsOrder[4] = 1; _aiPairsOrder[5] = 0; _blMessages = new BindingList <Property> { new Property(DateTime.Now, Translate("ProgramVersion")) }; _SelectedTask = null; _isDragOverTasks = _isProgressBarIndeterminate = false; _iProgressBarValue = 0; _iProgressBarMaximum = ciProgrssBarDefaultMaximum; _UserInterfaceTimer = new DispatcherTimer(); _UserInterfaceTimer.Tick += new EventHandler(UserInterfaceTimerTick); _UserInterfaceTimer.Interval = new TimeSpan(0, 0, 0, 0, 250); sTemporaryDirectory = Path.GetTempPath(); ExecuteReadDrivesAndKeys(); dcCompare = new DelegateCommand(ExecuteCompare, CanExecuteCompare); dcF5 = new DelegateCommand(ExecuteF5, CanExecuteF5); dcSelectDestination = new DelegateCommand(ExecuteSelectDestination); dcSelectSource = new DelegateCommand(ExecuteSelectSource); dcSwap = new DelegateCommand(ExecuteSwap, CanExecuteSwap); dcSynchronizeCancelOrRecompare = new DelegateCommand(ExecuteSynchronizeCancelOrRecompare, CanExecuteSynchronizeCancelOrRecompare); }
public Promise OpenForNewConnections() { isListening = true; listeningDeferred = Deferred.Create(); var startListeningDeferred = Deferred.Create(); BackgroundThread t = null; t = new BackgroundThread(() => { try { listener = new TcpListener(IPAddress.Any, port); listener.Start(); } catch (Exception ex) { startListeningDeferred.Reject(ex); return; } // we have started listening startListeningDeferred.Resolve(); try { while (isListening && t.IsExpired == false) { Socket socket; try { socket = listener.AcceptSocket(TimeSpan.FromSeconds(1)); if (t.IsExpired) { return; } } catch (TimeoutException) { continue; } var connection = new RemoteSocketConnection() { ClientId = (socket.RemoteEndPoint as IPEndPoint).Address.ToString() + ":" + (socket.RemoteEndPoint as IPEndPoint).Port, RemoteSocket = socket, MessageReceived = this.MessageReceived, }; this.OnDisposed(connection.Dispose); connection.Listen(); connections.Add(connection.ClientId, connection); ClientConnected.Fire(connection); } listener.Stop(); listeningDeferred.Resolve(); } catch (Exception ex) { listeningDeferred.Reject(ex); } finally { listeningDeferred = null; } }); this.OnDisposed(t.Dispose); t.Start(); return(startListeningDeferred.Promise); }
public Form1() { InitializeComponent(); BackgroundThread.RunWorkerAsync(); }
public new void Dispose() { BackgroundThread.Abort(); }
public MetroWindow() { Initialized += delegate { WindowStyle = WindowStyle.SingleBorderWindow; }; Loaded += delegate { GoToState(); switch (SizeToContent) { case SizeToContent.WidthAndHeight: case SizeToContent.Height: case SizeToContent.Width: SizeToContent = SizeToContent.Manual; Width = ActualWidth - 16; Height = ActualHeight - 32 - 7 + 3; /* * // 解决何必DLL到EXE中之后残留的Bug * if (!File.Exists(Path.StartPath + @"\Arthas.dll")) * { * // Height = Height + 10; * // Width = Width + 10; // 可能某些情况下不需要,但是无法获取到这些情况,所以全部加10像素,一般来说不会有问题 * } */ break; default: Height = ActualHeight + 32; break; } MinWidth = MinWidth == 0.0 ? Width : MinWidth; MinHeight = MinHeight == 0.0 ? Height : MinHeight; if (ResizeMode == ResizeMode.CanMinimize || ResizeMode == ResizeMode.NoResize) { MaxWidth = Width; MaxHeight = Height; } Left = (Screen.ScreenWidthLogic - Width) / 2; Top = (Screen.ScreenHeightLogic - Height) / 3; }; KeyUp += delegate(object sender, KeyEventArgs e) { if (e.Key == Key.Escape && EscClose) { Close(); } }; Closing += delegate { if (BackgroundThread != null) { BackgroundThread.Abort(); } }; StateChanged += delegate { if (ResizeMode == ResizeMode.CanMinimize || ResizeMode == ResizeMode.NoResize) { if (WindowState == WindowState.Maximized) { WindowState = WindowState.Normal; } } }; #if DEBUG ContentRendered += delegate { if (Debugger.IsAttached) { Title += " 编译器调试模式"; } else { Title += " 调试模式"; } Debug.WriteLine("当前处于调试版本,请勿发布!!!"); }; #endif Utility.Refresh(this); }