Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxXor committed Feb 8, 2021
2 parents bee3f76 + 2dbf7fd commit 16a4702
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
10 changes: 9 additions & 1 deletion Quasar.Client/Networking/QuasarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ public void ConnectLoop()

while (Connected) // hold client open
{
_token.WaitHandle.WaitOne(1000);
try
{
_token.WaitHandle.WaitOne(1000);
}
catch (Exception e) when (e is NullReferenceException || e is ObjectDisposedException)
{
Disconnect();
return;
}
}

if (_token.IsCancellationRequested)
Expand Down
8 changes: 4 additions & 4 deletions Quasar.Client/QuasarApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ public void Run()
{
// decrypt and verify the settings
if (!Settings.Initialize())
Application.Exit();
Environment.Exit(1);

ApplicationMutex = new SingleInstanceMutex(Settings.MUTEX);

// check if process with same mutex is already running on system
if (!ApplicationMutex.CreatedNew)
Application.Exit();
Environment.Exit(2);

FileHelper.DeleteZoneIdentifier(Application.ExecutablePath);

Expand All @@ -124,7 +124,7 @@ public void Run()
try
{
installer.Install();
Application.Exit();
Environment.Exit(3);
}
catch (Exception e)
{
Expand Down Expand Up @@ -165,7 +165,7 @@ public void Run()
// Start connection loop on new thread and dispose application once client exits.
// This is required to keep the UI thread responsive and run the message loop.
_connectClient.ConnectLoop();
Application.Exit();
Environment.Exit(0);
}).Start();
}
}
Expand Down
9 changes: 6 additions & 3 deletions Quasar.Client/User/ActivityDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,28 @@ public void Start()
/// </summary>
private void UserActivityThread()
{
while (!_token.WaitHandle.WaitOne(10))
try
{
if (IsUserIdle())
{
if (_lastUserStatus != UserStatus.Idle)
{
_lastUserStatus = UserStatus.Idle;
_client.Send(new SetUserStatus {Message = _lastUserStatus});
_client.Send(new SetUserStatus { Message = _lastUserStatus });
}
}
else
{
if (_lastUserStatus != UserStatus.Active)
{
_lastUserStatus = UserStatus.Active;
_client.Send(new SetUserStatus {Message = _lastUserStatus});
_client.Send(new SetUserStatus { Message = _lastUserStatus });
}
}
}
catch (Exception e) when (e is NullReferenceException || e is ObjectDisposedException)
{
}
}

/// <summary>
Expand Down

0 comments on commit 16a4702

Please sign in to comment.