public void RemoveEventListener(enEventID enEventId, OnEventHandler onEventHandler) { if (m_eventMap[(int)enEventId] != null) { m_eventMap[(int)enEventId] = (OnEventHandler)Delegate.Remove(m_eventMap[(int)enEventId], onEventHandler); } }
/// <summary> /// Constructs an event Tracer. /// </summary> /// <param name="target">The object whose events are to be hooked</param> /// <param name="handler">User-supplied method gets called whenever the /// target raises a hooked event</param> public Tracer(object target, OnEventHandler handler) { Debug.Assert(target != null); m_type = target.GetType(); m_target = target; m_handler = handler; }
/// <summary> /// Constructs an event TracerEx. /// </summary> /// <param name="target">The object whose events are to be hooked</param> /// <param name="handler">User-supplied method gets called whenever the /// target raises a hooked event</param> public TracerEx(object target, OnEventHandler handler) { Debug.Assert(target != null); m_type = (Type)target; m_target = target; m_handler = handler; }
private void StartRAT() { _handler += _signalHandler.Handler; Program.SetConsoleCtrlHandler(_handler, true); ServicePointManager.UseNagleAlgorithm = false; _connectionHandler.RequestLoop(); }
/// <summary> /// 添加监听(订阅): /// </summary> /// <param name="eventName">事件名</param> /// <param name="handler">句柄</param> public void AddListener(string eventName, OnEventHandler handler) { if (this.events.ContainsKey(eventName)) { this.events[eventName] += handler; } else { this.events.Add(eventName, handler); } }
/// <summary> /// 取消监听(订阅) /// </summary> /// <param name="eventName">事件名</param> /// <param name="handler">句柄</param> public void RemoveListener(string eventName, OnEventHandler handler) { if (this.events.ContainsKey(eventName)) { this.events[eventName] -= handler; if (this.events[eventName] == null) { this.events.Remove(eventName); } } }
public void AddOnEvent(StateType type, OnEventHandler func) { if (onEventState.ContainsKey(type)) { onEventState [type] += func; } else { onEventState [type] = func; } }
//订阅者 public void AddEventListener(string name, OnEventHandler handler) { if (this._eventListeners.ContainsKey(name)) { this._eventListeners[name] += handler; } else { this._eventListeners.Add(name, handler); } }
///////////////////////////////////////////////////////////////////////// // <summary> // イベント処理 // </summary> // <param name="delEventHandler">イベント処理デリゲート</param> // <remarks></remarks> protected void OnEventExecute(string sEventName, OnEventHandler delEventHandler) { // エラートラップ try { // ログ生成 m_log = new TTLog(m_sSysNm, m_sPgNm); // // 環境生成 m_config = new TTConfig(m_sConfigPath); // // ログテーブル設定 m_log.SetLogInfo(m_config, m_sLogTbl, m_sStfCd, m_sStfNm); // // DB接続 m_npgDB = TTCommon.DBConnect(m_config); // // 開始ログ m_log.EventStart(sEventName); // // イベント処理実行 delEventHandler(); } catch (TTConfig.TTConfigError ex) { m_log.Error("環境設定エラー", ex); } catch (IcelineExceptionNpgDBConnect ex) { m_log.Error("DB接続エラー", ex); } catch (System.Threading.ThreadAbortException) { // Redirectを実行するとこの例外が発生する為、Nop } catch (Exception ex) { m_log.Error("想定外エラー", ex); } finally { // 終了ログ m_log.EventEnd(sEventName); // // 後処理 m_log.Dispose(); // if (m_npgDB != null) { m_npgDB.Dispose(); m_npgDB = null; } } }
private void DispathEvent(Event @event) { @event.m_isused = true; OnEventHandler callback = m_eventMap[(int)@event.EnEventId]; if (callback != null) { callback(@event); } @event.Clear(); }
public void RemoveEventListener(string name, OnEventHandler handler) { if (!this._eventListeners.ContainsKey(name)) { return; } this._eventListeners[name] -= handler; if (this._eventListeners[name] == null) { this._eventListeners.Remove(name); } }
public void AddEventListener(enEventID enEventId, OnEventHandler onEventHandler) { if (m_eventMap[(int)enEventId] == null) { m_eventMap[(int)enEventId] = delegate { }; m_eventMap[(int)enEventId] = (OnEventHandler)Delegate.Combine(m_eventMap[(int)enEventId], onEventHandler); } else { //加之前先移除 防止一个方法执行多次 m_eventMap[(int)enEventId] = (OnEventHandler)Delegate.Remove(m_eventMap[(int)enEventId], onEventHandler); m_eventMap[(int)enEventId] = (OnEventHandler)Delegate.Combine(m_eventMap[(int)enEventId], onEventHandler); } }
public SumideroEvento(OnEventHandler manipulador) { this.manipulador = manipulador; }
/// <summary> /// Unhooks all events when Tracer is Disposed. /// </summary> public void Dispose() { if (EventsHookedCount > 0) { UnhookAllEvents(); } m_target = null; m_handler = null; }
public static extern bool SetConsoleCtrlHandler(OnEventHandler handler, bool add);
public EventProxy(Tracer parent, object target, string name) { m_handler = parent.m_handler; m_target = target; m_name = name; }
/// <summary> /// ���������������� ����������� ����� �� ���� RAID /// </summary> /// <param name="fullFileName">������ ��� ����� ��� ����������������� �����������</param> /// <param name="dataCount">���������� �������� �����</param> /// <param name="eccCount">���������� ����� ��� ��������������</param> /// <param name="codecType">��� ������ ����-�������� (�� ���� �������)</param> /// <param name="runAsSeparateThread">��������� � ��������� ������?</param> /// <returns>��������� ���� ��������</returns> public bool StartToProtect(String fullFileName, int dataCount, int eccCount, int codecType, bool runAsSeparateThread) { // ���� ����� ����������� ����� �������� - �� ��������� ��������� ������ if(InProcessing) { return false; } // ���������� ���� ������������ ���������� ����� �������� ������ this.processedOK = false; // ���������� ��������� ����������� ��������� ����������-������ this.finished = false; // ���� ��� ����� �� ����������� if( (fullFileName == null) || (fullFileName == "") ) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ���������� ��������� ���� �� ������� ����� ����� this.path = this.eFileNamer.GetPath(fullFileName); // ���������� ��������� ����� �� ������� ����� ����� this.fileName = this.eFileNamer.GetShortFileName(fullFileName); // ���� �������� ���� �� ����������, �������� �� ������ if(!File.Exists(this.path + this.fileName)) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ��������� ���������� �������� ����� this.dataCount = dataCount; // ��������� ���������� ����� ��� �������������� this.eccCount = eccCount; // ��������� ��� ������ ����-�������� this.codecType = codecType; // ������������� �� ��������� this.eFileSplitter.OnUpdateFileSplittingProgress = OnUpdateFileSplittingProgress; this.eFileSplitter.OnFileSplittingFinish = OnFileSplittingFinish; this.eFileCodec.OnUpdateRSMatrixFormingProgress = OnUpdateRSMatrixFormingProgress; this.eFileCodec.OnRSMatrixFormingFinish = OnRSMatrixFormingFinish; this.eFileCodec.OnUpdateFileStreamsOpeningProgress = OnUpdateFileStreamsOpeningProgress; this.eFileCodec.OnFileStreamsOpeningFinish = OnFileStreamsOpeningFinish; this.eFileCodec.OnStartedRSCoding = OnStartedRSCoding; this.eFileCodec.OnUpdateFileCodingProgress = OnUpdateFileCodingProgress; this.eFileCodec.OnFileCodingFinish = OnFileCodingFinish; this.eFileCodec.OnUpdateFileStreamsClosingProgress = OnUpdateFileStreamsClosingProgress; this.eFileCodec.OnFileStreamsClosingFinish = OnFileStreamsClosingFinish; this.eFileAnalyzer.OnUpdateFileAnalyzeProgress = OnUpdateFileAnalyzeProgress; this.eFileAnalyzer.OnFileAnalyzeFinish = OnFileAnalyzeFinish; // ���������, ��� ����� ������ ����������� this.exitEvent[0].Reset(); this.executeEvent[0].Set(); this.wakeUpEvent[0].Reset(); this.finishedEvent[0].Reset(); // ���� �������, ��� �� ��������� ������ � ��������� ������, // ��������� � ������ if(!runAsSeparateThread) { // �������� ���� �� ����������� (�������� ���) Protect(); // ���������� ��������� ��������� return this.processedOK; } // ������� ����� ����������� ������... this.thrRecoveryStarCore = new Thread(new ThreadStart(Protect)); //...����� ���� ��� ���... this.thrRecoveryStarCore.Name = "RecoveryStarCore.Protect()"; //...������������� ��������� ��������� ������... this.thrRecoveryStarCore.Priority = this.threadPriority; //...� ��������� ��� this.thrRecoveryStarCore.Start(); // ��������, ��� ��� ��������� return true; }
/// <summary> /// ������������ ����������������� ������ ������ /// </summary> /// <param name="fullFileName">������ ��� ����� ��� ������������</param> /// <param name="fastExtraction">������������ ������� ���������� �� ����� (��� �������� CRC-64)?</param> /// <param name="runAsSeparateThread">��������� � ��������� ������?</param> /// <returns>��������� ���� ��������</returns> public bool StartToTest(String fullFileName, bool fastExtraction, bool runAsSeparateThread) { // ���� ����� ����������� ����� �������� - �� ��������� ��������� ������ if(InProcessing) { return false; } // ���������� ���� ������������ ���������� ����� �������� ������ this.processedOK = false; // ���������� ��������� ����������� ��������� ����������-������ this.finished = false; // ���� ��� ����� �� ����������� if( (fullFileName == null) || (fullFileName == "") ) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ���������� ��������� ���� �� ������� ����� ����� this.path = this.eFileNamer.GetPath(fullFileName); // ���������� ��������� ����� �� ������� ����� ����� this.fileName = this.eFileNamer.GetShortFileName(fullFileName); // ���� �������� ���� �� ����������, �������� �� ������ if(!File.Exists(this.path + this.fileName)) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ������������� �������� ��� ����� �� ����������� �������, // � � ���������� �������� ��������� "fileName", "dataCount", "eccCount", "codecType" if(!this.eFileNamer.Unpack(ref this.fileName, ref this.dataCount, ref this.eccCount, ref this.codecType)) { return false; } // ������������ ������� ���������� �� ����� (��� �������� CRC-64)? this.fastExtraction = fastExtraction; // ������������� �� ��������� this.eFileAnalyzer.OnUpdateFileAnalyzeProgress = OnUpdateFileAnalyzeProgress; this.eFileAnalyzer.OnFileAnalyzeFinish = OnFileAnalyzeFinish; this.eFileAnalyzer.OnGetDamageStat = OnGetDamageStat; // ���������, ��� ����� ������ ����������� this.exitEvent[0].Reset(); this.executeEvent[0].Set(); this.wakeUpEvent[0].Reset(); this.finishedEvent[0].Reset(); // ���� �������, ��� �� ��������� ������ � ��������� ������, // ��������� � ������ if(!runAsSeparateThread) { // ��������������� ���� �� ������������ ������ � ���������� ������ Test(); // ���������� ��������� ��������� return this.processedOK; } // ������� ����� �������������� ������... this.thrRecoveryStarCore = new Thread(new ThreadStart(Test)); //...����� ���� ��� ���... this.thrRecoveryStarCore.Name = "RecoveryStarCore.Test()"; //...������������� ��������� ��������� ������... this.thrRecoveryStarCore.Priority = this.threadPriority; //...� ��������� ��� this.thrRecoveryStarCore.Start(); // ��������, ��� ��� ��������� return true; }
public EventProxy(TracerEx parent, object target, string name) { m_handler = parent.m_handler; m_target = target; m_name = name; }