public static async Task ShowWallpaper(WallpaperModel wallpaper, params int[] screenIndexs) { if (_ipc == null) { _ipc = new IPCHelper(IPCHelper.ServerID, IPCHelper.RemoteRenderID); } if (_currentProcess == null) { var pList = Process.GetProcessesByName("LiveWallpaperEngineRender"); _currentProcess = pList?.Length > 0 ? pList[0] : null; if (_currentProcess == null) { _currentProcess = Process.Start("LiveWallpaperEngineRender.exe"); //等待render初始完成 await _ipc.Wait <Ready>(); } } //显示壁纸 await _ipc.Send(new InvokeRender() { InvokeMethod = nameof(IRender.ShowWallpaper), Parameters = new object[] { wallpaper, screenIndexs }, }); }
private static void Main_Load(object sender, EventArgs e) { _mainForm.Load -= Main_Load; _ipc.Send(new Ready()); }