Changeset 1054
- Timestamp:
- 5/11/2009 10:39:43 AM (4 years ago)
- File:
-
- 1 edited
-
branches/eraser6/Eraser/Program.cs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Eraser/Program.cs
r1013 r1054 299 299 //If no other instances are running, set up our pipe server so clients 300 300 //can connect and give us subsequent command lines. 301 if (Is AlreadyRunning)301 if (IsFirstInstance) 302 302 { 303 303 try … … 308 308 309 309 //Initialise and run the program. 310 if (OnInitInstance(this) && MainForm != null) 310 bool ShowMainForm = OnInitInstance(this); 311 if (MainForm == null) 312 return false; 313 314 //Handle the exit instance event. This will occur when the main form 315 //has been closed. 316 mainForm.FormClosed += OnExitInstance; 317 318 if (ShowMainForm) 311 319 Application.Run(MainForm); 312 320 else … … 318 326 Application.Run(); 319 327 } 328 320 329 return true; 321 330 } 322 331 finally 323 332 { 324 //Since the program was initialised we must let the program clean up.325 OnExitInstance(this);326 333 pipeServer.Abort(); 327 334 } … … 455 462 /// Gets whether another instance of the program is already running. 456 463 /// </summary> 457 public bool Is AlreadyRunning464 public bool IsFirstInstance 458 465 { 459 466 get … … 467 474 /// run is called if it is non-null and if its Visible property is true. 468 475 /// </summary> 469 public Form MainForm 470 { 471 get 472 { 473 return mainForm; 474 } 475 set 476 { 477 mainForm = value; 478 } 479 } 476 public Form MainForm { get; set; } 480 477 481 478 #region Events … … 547 544 /// <param name="sender">The sender of the event.</param> 548 545 private void OnExitInstance(object sender) 546 { 547 if (ExitInstance != null) 548 ExitInstance(sender); 549 } 550 551 /// <summary> 552 /// Broadcasts the ExitInstance event after getting the FormClosed event from 553 /// the application's main form. 554 /// </summary> 555 /// <param name="sender">The sender of the event.</param> 556 private void OnExitInstance(object sender, FormClosedEventArgs e) 549 557 { 550 558 if (ExitInstance != null)
Note: See TracChangeset
for help on using the changeset viewer.
