Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute method in running program instead of launching a new instance

I am writing a weather application. I am integrating it with the taskbar. When you right click on its icon on the taskbar it show you the current temperature, etc. Currently if you click on the text that says "Current: ..." it opens another instance of the application.

Screenshot:

Weather taskbar

How can I get this to run a procedure or function in my program? So if the user clicks on the "Current: ..." it should open a new form in the same application. It should not open another application?

My code is currently:

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();
like image 203
joostehost Avatar asked Oct 05 '12 13:10

joostehost


1 Answers

Look here: The Weekly Source Code 31- Single Instance WinForms. It will allow you to open only one program instance, but using VisualBasic instead of a Mutex.

like image 131
Daro Avatar answered Oct 06 '22 00:10

Daro