在运行程序时执行方法而不是启动新实例

joo*_*ost 6 c# windows taskbar windows-7 winforms

我正在写一份天气应用程序.我正在将它与任务栏集成.当您右键单击任务栏上的图标时,它会显示当前温度等.当前,如果单击"当前:..."文本,它将打开该应用程序的另一个实例.

截图:

天气任务栏

如何在程序中运行程序或函数?因此,如果用户点击"当前:...",它应该在同一个应用程序中打开一个新表单.它不应该打开另一个应用程序?

我的代码目前是:

JumpListCustomCategory userActionsCategory = new JumpListCustomCategory("Weather");
userActionLink.Arguments = "-1";
JumpListLink userActionLink = new JumpListLink(Assembly.GetEntryAssembly().Location, Conditions + ": " + reader.ReadToEnd());
userActionLink.IconReference = new IconReference(testicon, 0);
userActionsCategory.AddJumpListItems(userActionLink);
list.AddCustomCategories(userActionsCategory);
list.Refresh();
Run Code Online (Sandbox Code Playgroud)

Dar*_*aro 1

看这里:每周源代码31-单实例WinForms。它将允许您仅打开一个程序实例,但使用 VisualBasic 而不是互斥体。