Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace DbMon.NET {
- public partial class DebugMonitorComponent:Component {
- bool _enabled = true;
- bool _started;
- bool _cancelled;
- int _currentFilterPID = 0;
- public Dictionary<int,string> ProcessList { get; set; }
- OutputQueue<DebugItem> _output;
- public bool Started {
- get {
- return _started;
- }
- protected set {
- _started = value;
- }
- }
- public bool Cancelled {
- get {
- return _cancelled;
- }
- protected set {
- _cancelled = value;
- }
- }
- public bool IsEnabled {
- get { return _enabled; }
- set { _enabled = value; }
- }
- public int CurrentFilterPID {
- get { return _currentFilterPID; }
- set { _currentFilterPID = value; }
- }
- public DebugMonitorComponent() {
- InitializeComponent();
- ProcessList = new Dictionary<int,string>();
- }
- public DebugMonitorComponent(IContainer container) {
- container.Add(this);
- InitializeComponent();
- }
- public virtual void Start(OutputQueue<DebugItem> output) {
- _output = output;
- if(this.DesignMode) {
- MessageBox.Show("Start(); DesignMode=true");
- return;
- }
- Started = true;
- Cancelled = false;
- DebugMonitor.OnOutputDebugString -= new OnOutputDebugStringHandler(DebugMonitor_OnOutputDebugString);
- DebugMonitor.OnOutputDebugString += new OnOutputDebugStringHandler(DebugMonitor_OnOutputDebugString);
- DebugMonitor.Start();
- }
- public virtual void Stop() {
- if(this.DesignMode) {
- MessageBox.Show("Stop(); DesignMode=true");
- return;
- }
- Cancelled = true;
- Started = false;
- DebugMonitor.Stop();
- DebugMonitor.OnOutputDebugString -= new OnOutputDebugStringHandler(DebugMonitor_OnOutputDebugString);
- }
- void DebugMonitor_OnOutputDebugString(int pid,string text) {
- if(!this._enabled)
- return;
- if(_currentFilterPID > 0)
- if(_currentFilterPID != pid)
- return;
- _output.EnqueueOutput(new DebugItem(pid,text));
- }
- public void RemoveProcess(int[] pids) {
- foreach(var item in pids) {
- ProcessList.Remove(item);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment