mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix all warnings & Trim (#2226)
* Fix AutoFishing crash * Fix all warnings * Remove DotNetZip. * Fix the usage of HttpClient.
This commit is contained in:
parent
4aa6c1c99f
commit
1d52d1eadd
227 changed files with 2201 additions and 43564 deletions
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace MinecraftClient
|
||||
|
|
@ -12,12 +9,12 @@ namespace MinecraftClient
|
|||
/// <typeparam name="T">Type of the return value</typeparam>
|
||||
public class TaskWithResult<T>
|
||||
{
|
||||
private AutoResetEvent resultEvent = new AutoResetEvent(false);
|
||||
private Func<T> task;
|
||||
private T result = default(T);
|
||||
private Exception exception = null;
|
||||
private readonly AutoResetEvent resultEvent = new(false);
|
||||
private readonly Func<T> task;
|
||||
private T? result = default;
|
||||
private Exception? exception = null;
|
||||
private bool taskRun = false;
|
||||
private object taskRunLock = new object();
|
||||
private readonly object taskRunLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Create a new asynchronous task with return value
|
||||
|
|
@ -48,17 +45,16 @@ namespace MinecraftClient
|
|||
get
|
||||
{
|
||||
if (taskRun)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else throw new InvalidOperationException("Attempting to retrieve the result of an unfinished task");
|
||||
return result!;
|
||||
else
|
||||
throw new InvalidOperationException("Attempting to retrieve the result of an unfinished task");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the exception thrown by the inner delegate, if any
|
||||
/// </summary>
|
||||
public Exception Exception
|
||||
public Exception? Exception
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -120,7 +116,7 @@ namespace MinecraftClient
|
|||
if (exception != null)
|
||||
throw exception;
|
||||
|
||||
return result;
|
||||
return result!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue