-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature - AutoUpdate Improvements V. 5.1.5.2 🔥
- Loading branch information
1 parent
474f3c4
commit c654ef3
Showing
7 changed files
with
115 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.IO.MemoryMappedFiles; | ||
using System.Threading; | ||
using System.Windows; | ||
using System.IO; | ||
using System; | ||
|
||
namespace CS2_AutoAccept | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
// Check if another instance of the app is already running | ||
Mutex mutex = new Mutex(true, "CS2-AutoAccept by tsgsOFFICIAL", out bool createdNew); | ||
string[] args = Environment.GetCommandLineArgs(); | ||
bool updated = false; | ||
|
||
foreach (string arg in args) | ||
{ | ||
// Application was updated | ||
if (arg.ToLower().Equals("--updated")) | ||
{ | ||
updated = true; | ||
break; | ||
} | ||
} | ||
|
||
// If another instance exists, trigger the event and exit | ||
if (!createdNew && !updated) | ||
{ | ||
// Create a MemoryMappedFile to notify the other instance | ||
using (MemoryMappedFile mmf = MemoryMappedFile.CreateOrOpen("CS2_AutoAccept_MMF", 1024)) | ||
using (MemoryMappedViewStream view = mmf.CreateViewStream()) | ||
{ | ||
BinaryWriter writer = new BinaryWriter(view); | ||
EventWaitHandle signal = new EventWaitHandle(false, EventResetMode.AutoReset, "CS2_AutoAccept_Event"); | ||
writer.Write("New instance started"); | ||
signal.Set(); // Signal the other instance that it should come to the front | ||
} | ||
|
||
// Shutdown the second instance | ||
Current.Shutdown(); | ||
mutex.ReleaseMutex(); | ||
return; | ||
} | ||
|
||
// Run the WPF application | ||
base.OnStartup(e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.5 KB
(100%)
CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.exe
Binary file not shown.
Binary file modified
BIN
+624 Bytes
(100%)
CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.pdb
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters