Skip to content
Snippets Groups Projects
Commit e3f075ed authored by noberumotto's avatar noberumotto
Browse files

添加应用监听事件数据封装

parent 6e337dfc
Branches
No related merge requests found
using System;
using Core.Models.AppObserver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -6,5 +7,5 @@ using System.Threading.Tasks;
namespace Core.Event
{
public delegate void ObserverEventHandler(string processName, string description, string file);
public delegate void ObserverEventHandler(AppObserverEventArgs args);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Core.Models.AppObserver
{
public class AppObserverEventArgs
{
private IntPtr _handle;
private string _processName;
private string _description;
private string _file;
public string ProcessName { get { return _processName; } }
public string Description { get { return _description; } }
public string File { get { return _file; } }
public IntPtr Handle { get { return _handle; } }
public AppObserverEventArgs(string processName, string description, string file, IntPtr handle)
{
_processName = processName;
_description = description;
_file = file;
_handle = handle;
}
}
}
using Core.Event;
using Core.Librarys;
using Core.Models.AppObserver;
using Core.Servicers.Interfaces;
using System;
using System.Collections.Generic;
......@@ -40,7 +41,6 @@ namespace Core.Servicers.Instances
private async void Handle(IntPtr hwnd)
{
Debug.WriteLine(hwnd);
string processName = String.Empty, processFileName = String.Empty, processDescription = String.Empty;
var processResult = await Task.Run(() =>
......@@ -102,7 +102,7 @@ namespace Core.Servicers.Instances
return processName;
});
EventInvoke(processName, processDescription, processFileName);
EventInvoke(processName, processDescription, processFileName, hwnd);
}
/// <summary>
......@@ -170,9 +170,10 @@ namespace Core.Servicers.Instances
}
return new string[] { processName, processFileName, processID.ToString() };
}
private void EventInvoke(string processName, string description, string filename)
private void EventInvoke(string processName, string description, string filename, IntPtr handle)
{
OnAppActive?.Invoke(processName, description, filename);
var args = new AppObserverEventArgs(processName, description, filename, handle);
OnAppActive?.Invoke(args);
}
public void Stop()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment