public static void Initialize(ScanSense sense) { try { ScanSensitivity = sense; EventsManager = new KAVE.BaseEngine.KavprotEvents(); AsyncInvoke inv = new AsyncInvoke(VirusReportService.Initialize); inv.BeginInvoke(null, null); // load scanners AsyncInvoke sinv = new AsyncInvoke(Init); sinv.BeginInvoke(null, null); if (SettingsManager.TurboMode) { AsyncInvoke ssinv = new AsyncInvoke(VDB.Initialize); ssinv.BeginInvoke(null, null); } else { VDB.Initialize(); } } catch (Exception ex) { AntiCrash.LogException(ex); } }
public void CallbackAsyncDelete() { //回调委托 AsyncCallback callBack = DelegateCallback; //自定义委托 AsyncInvoke method1 = TestAsyncInvoke.Method1; Console.WriteLine($"Calling BeginInvike on Thread {Thread.CurrentThread.ManagedThreadId}"); IAsyncResult asyncResult = method1.BeginInvoke(callBack, method1);//以BeginInvoke开始,第二个参数表示状态对象 return; }
public void CallbackAsyncDelegate() { AsyncCallback callBack = DelegateCallback; AsyncInvoke method1 = TestAsyncInvoke.Method1; Console.WriteLine( $"Calling BeginInvoke on Thread {Thread.CurrentThread.ManagedThreadId}"); IAsyncResult asyncResult = method1.BeginInvoke(callBack, method1); // No need to poll or use the WaitOne method here, so return to the calling method. return; }
public void PollAsyncDelegate() { AsyncInvoke MI = new AsyncInvoke(TestAsyncInvoke.Method1); IAsyncResult AR = MI.BeginInvoke(null, null); while (!AR.IsCompleted) { System.Threading.Thread.Sleep(100); Console.WriteLine('.'); } Console.WriteLine("Finished Polling"); try { int retVal = MI.EndInvoke(AR); Console.WriteLine("RetVal (Polling): " + retVal); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static void Initialize(KavprotInitialization init) { try { // init settings SettingsManager.Initialize(); if (SettingsManager.TurboMode) { AsyncInvoke ainv = new AsyncInvoke(KavprotVoice.Initialize); ainv.BeginInvoke(null, null); // Activation.Initialize(); //if (!Activation.Expired) //{ if (init == KavprotInitialization.Full) { // init monitors AsyncInvoke inv = new AsyncInvoke(InitMonitors); inv.BeginInvoke(null, null); // init engine AVEngine.Initialize(SettingsManager.Scansense); if (SettingsManager.KavprotRemoteControl) { AsyncInvoke dinv = new AsyncInvoke(KavprotRemoteControl.Init); dinv.BeginInvoke(null, null); AsyncInvoke tinv = new AsyncInvoke(KavprotRemoteControl.ReceiveDataFromMobile); tinv.BeginInvoke(null, null); } AntivirusState.SetProtection(true); } else { // init engine AVEngine.Initialize(SettingsManager.Scansense); } //} //else //{ // MessageBox.Show("Kavprot will be closed after you click ok", "Activation", MessageBoxButtons.OK, MessageBoxIcon.Warning); // ShutDown(); //} } else { KavprotVoice.Initialize(); //Activation.Initialize(); //if (!Activation.Expired) //{ if (init == KavprotInitialization.Full) { // init monitors InitMonitors(); // init engine AVEngine.Initialize(SettingsManager.Scansense); if (SettingsManager.KavprotRemoteControl) { KavprotRemoteControl.Init(); AsyncInvoke inv = new AsyncInvoke(KavprotRemoteControl.ReceiveDataFromMobile); inv.BeginInvoke(null, null); } AntivirusState.SetProtection(true); } else { // init engine AVEngine.Initialize(SettingsManager.Scansense); } //} //else //{ // MessageBox.Show("Kavprot will be closed after you click ok", "Activation", MessageBoxButtons.OK, MessageBoxIcon.Warning); // ShutDown(); //} } } catch { } }