mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-22 19:18:47 +00:00
Call ConfigureAwait(false) for all awaited tasks
This commit is contained in:
parent
7fe303c4eb
commit
66fe507b8d
@ -1,4 +1,4 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using VpSharp.Extensions;
|
||||
using VpSharp.Internal;
|
||||
@ -334,7 +334,7 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
||||
|
||||
if (isSelf && isNewWorld)
|
||||
{
|
||||
await _client.EnterAsync(world);
|
||||
await _client.EnterAsync(world).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
nint handle = _client.NativeInstanceHandle;
|
||||
@ -343,7 +343,7 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(world))
|
||||
{
|
||||
await _client.EnterAsync(world);
|
||||
await _client.EnterAsync(world).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// state change self
|
||||
|
@ -150,7 +150,7 @@ public sealed class VirtualParadiseUser : IEquatable<VirtualParadiseUser>
|
||||
vp_invite(_client.NativeInstanceHandle, Id, world, x, y, z, (float) yaw, (float) pitch);
|
||||
}
|
||||
|
||||
ReasonCode reason = await taskCompletionSource.Task;
|
||||
ReasonCode reason = await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
return reason switch
|
||||
{
|
||||
ReasonCode.Success => InviteResponse.Accepted,
|
||||
@ -194,7 +194,7 @@ public sealed class VirtualParadiseUser : IEquatable<VirtualParadiseUser>
|
||||
taskCompletionSource = _client.AddJoinCompletionSource(reference);
|
||||
}
|
||||
|
||||
ReasonCode reason = await taskCompletionSource.Task;
|
||||
ReasonCode reason = await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
Location? location = null;
|
||||
|
||||
if (reason == ReasonCode.Success)
|
||||
@ -217,13 +217,13 @@ public sealed class VirtualParadiseUser : IEquatable<VirtualParadiseUser>
|
||||
|
||||
var position = new Vector3d(x, y, z);
|
||||
var rotation = Quaternion.CreateFromYawPitchRoll(yaw, pitch, 0);
|
||||
VirtualParadiseWorld world = (await _client.GetWorldAsync(worldName))!;
|
||||
VirtualParadiseWorld world = (await _client.GetWorldAsync(worldName).ConfigureAwait(false))!;
|
||||
|
||||
location = new Location(world, position, rotation);
|
||||
|
||||
if (!suppressTeleport)
|
||||
{
|
||||
await avatar.TeleportAsync(location.Value);
|
||||
await avatar.TeleportAsync(location.Value).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public sealed class VirtualParadiseWorld : IEquatable<VirtualParadiseWorld>
|
||||
ArgumentNullException.ThrowIfNull(action);
|
||||
|
||||
var builder = new WorldSettingsBuilder(_client);
|
||||
await Task.Run(() => action(builder));
|
||||
await Task.Run(() => action(builder)).ConfigureAwait(false);
|
||||
|
||||
builder.SendChanges();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public sealed partial class VirtualParadiseClient
|
||||
{
|
||||
VirtualParadiseAvatar avatar = ExtractAvatar(sender);
|
||||
avatar = AddOrUpdateAvatar(avatar);
|
||||
avatar.User = await GetUserAsync(vp_int(sender, IntegerAttribute.UserId));
|
||||
avatar.User = await GetUserAsync(vp_int(sender, IntegerAttribute.UserId)).ConfigureAwait(false);
|
||||
|
||||
var args = new AvatarJoinedEventArgs(avatar);
|
||||
RaiseEvent(AvatarJoined, args);
|
||||
@ -165,7 +165,7 @@ public sealed partial class VirtualParadiseClient
|
||||
session = vp_int(sender, IntegerAttribute.AvatarSession);
|
||||
}
|
||||
|
||||
VirtualParadiseObject? virtualParadiseObject = await ExtractObjectAsync(sender);
|
||||
VirtualParadiseObject? virtualParadiseObject = await ExtractObjectAsync(sender).ConfigureAwait(false);
|
||||
var cell = virtualParadiseObject.Location.Cell;
|
||||
|
||||
virtualParadiseObject = AddOrUpdateObject(virtualParadiseObject);
|
||||
@ -174,7 +174,7 @@ public sealed partial class VirtualParadiseClient
|
||||
{
|
||||
if (_cellChannels.TryGetValue(cell, out Channel<VirtualParadiseObject>? channel))
|
||||
{
|
||||
await channel.Writer.WriteAsync(virtualParadiseObject);
|
||||
await channel.Writer.WriteAsync(virtualParadiseObject).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -202,7 +202,7 @@ public sealed partial class VirtualParadiseClient
|
||||
|
||||
if (_objects.TryGetValue(objectId, out VirtualParadiseObject? virtualParadiseObject))
|
||||
{
|
||||
cachedObject = await ExtractObjectAsync(sender); // data discarded, but used to pull type
|
||||
cachedObject = await ExtractObjectAsync(sender).ConfigureAwait(false); // data discarded, but used to pull type
|
||||
cachedObject.ExtractFromOther(virtualParadiseObject);
|
||||
|
||||
virtualParadiseObject.ExtractFromInstance(sender); // update existing instance
|
||||
@ -233,7 +233,7 @@ public sealed partial class VirtualParadiseClient
|
||||
|
||||
try
|
||||
{
|
||||
virtualParadiseObject = await GetObjectAsync(objectId);
|
||||
virtualParadiseObject = await GetObjectAsync(objectId).ConfigureAwait(false);
|
||||
}
|
||||
catch // any exception: we don't care about GetObject failing. ID is always available
|
||||
{
|
||||
@ -264,7 +264,7 @@ public sealed partial class VirtualParadiseClient
|
||||
}
|
||||
|
||||
VirtualParadiseAvatar? avatar = GetAvatar(session);
|
||||
var virtualParadiseObject = await GetObjectAsync(objectId);
|
||||
var virtualParadiseObject = await GetObjectAsync(objectId).ConfigureAwait(false);
|
||||
var args = new ObjectClickedEventArgs(avatar, virtualParadiseObject, clickPoint);
|
||||
RaiseEvent(ObjectClicked, args);
|
||||
}
|
||||
@ -288,7 +288,7 @@ public sealed partial class VirtualParadiseClient
|
||||
|
||||
if (_worldListChannel is not null)
|
||||
{
|
||||
await _worldListChannel.Writer.WriteAsync(world);
|
||||
await _worldListChannel.Writer.WriteAsync(world).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ public sealed partial class VirtualParadiseClient
|
||||
userId = vp_int(sender, IntegerAttribute.FriendUserId);
|
||||
}
|
||||
|
||||
VirtualParadiseUser? user = await GetUserAsync(userId);
|
||||
VirtualParadiseUser? user = await GetUserAsync(userId).ConfigureAwait(false);
|
||||
_friends.AddOrUpdate(userId, user, (_, _) => user);
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ public sealed partial class VirtualParadiseClient
|
||||
worldName = vp_string(sender, StringAttribute.TeleportWorld);
|
||||
}
|
||||
|
||||
VirtualParadiseWorld? world = string.IsNullOrWhiteSpace(worldName) ? CurrentWorld : await GetWorldAsync(worldName);
|
||||
VirtualParadiseWorld? world = string.IsNullOrWhiteSpace(worldName) ? CurrentWorld : await GetWorldAsync(worldName).ConfigureAwait(false);
|
||||
var location = new Location(world, position, rotation);
|
||||
|
||||
VirtualParadiseAvatar? avatar = GetAvatar(session);
|
||||
@ -458,7 +458,7 @@ public sealed partial class VirtualParadiseClient
|
||||
}
|
||||
|
||||
VirtualParadiseAvatar? avatar = GetAvatar(session);
|
||||
var vpObject = await GetObjectAsync(objectId);
|
||||
var vpObject = await GetObjectAsync(objectId).ConfigureAwait(false);
|
||||
|
||||
var args = new ObjectBumpEventArgs(avatar, vpObject, BumpPhase.End);
|
||||
RaiseEvent(ObjectBump, args);
|
||||
@ -500,7 +500,7 @@ public sealed partial class VirtualParadiseClient
|
||||
}
|
||||
|
||||
VirtualParadiseAvatar? avatar = GetAvatar(session);
|
||||
var vpObject = await GetObjectAsync(objectId);
|
||||
var vpObject = await GetObjectAsync(objectId).ConfigureAwait(false);
|
||||
|
||||
var args = new ObjectBumpEventArgs(avatar, vpObject, BumpPhase.Begin);
|
||||
RaiseEvent(ObjectBump, args);
|
||||
@ -519,7 +519,7 @@ public sealed partial class VirtualParadiseClient
|
||||
name = vp_string(NativeInstanceHandle, StringAttribute.JoinName);
|
||||
}
|
||||
|
||||
VirtualParadiseUser? user = await GetUserAsync(userId);
|
||||
VirtualParadiseUser? user = await GetUserAsync(userId).ConfigureAwait(false);
|
||||
var joinRequest = new JoinRequest(this, requestId, name, user);
|
||||
var args = new JoinRequestReceivedEventArgs(joinRequest);
|
||||
RaiseEvent(JoinRequestReceived, args);
|
||||
@ -553,8 +553,8 @@ public sealed partial class VirtualParadiseClient
|
||||
worldName = vp_string(sender, StringAttribute.InviteWorld);
|
||||
}
|
||||
|
||||
VirtualParadiseWorld? world = await GetWorldAsync(worldName);
|
||||
VirtualParadiseUser? user = await GetUserAsync(userId);
|
||||
VirtualParadiseWorld? world = await GetWorldAsync(worldName).ConfigureAwait(false);
|
||||
VirtualParadiseUser? user = await GetUserAsync(userId).ConfigureAwait(false);
|
||||
|
||||
var location = new Location(world, position, rotation);
|
||||
var request = new InviteRequest(this, requestId, avatarName, user, location);
|
||||
|
@ -25,7 +25,7 @@ public sealed partial class VirtualParadiseClient
|
||||
|
||||
if (_usersCompletionSources.TryGetValue(userId, out TaskCompletionSource<VirtualParadiseUser>? taskCompletionSource))
|
||||
{
|
||||
return await taskCompletionSource.Task;
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
taskCompletionSource = new TaskCompletionSource<VirtualParadiseUser>();
|
||||
@ -36,7 +36,7 @@ public sealed partial class VirtualParadiseClient
|
||||
vp_user_attributes_by_id(NativeInstanceHandle, userId);
|
||||
}
|
||||
|
||||
user = await taskCompletionSource.Task;
|
||||
user = await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
user = AddOrUpdateUser(user);
|
||||
|
||||
_usersCompletionSources.TryRemove(userId, out TaskCompletionSource<VirtualParadiseUser>? _);
|
||||
|
@ -115,7 +115,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
reason = await _connectCompletionSource.Task;
|
||||
reason = await _connectCompletionSource.Task.ConfigureAwait(false);
|
||||
|
||||
NoSuccess:
|
||||
switch (reason)
|
||||
@ -187,8 +187,8 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
/// <exception cref="TimeoutException">Connection to the world server timed out.</exception>
|
||||
public async Task<VirtualParadiseWorld> EnterAsync(string worldName, Vector3d position)
|
||||
{
|
||||
await EnterAsync(worldName);
|
||||
await CurrentAvatar!.TeleportAsync(position, Quaternion.Identity);
|
||||
await EnterAsync(worldName).ConfigureAwait(false);
|
||||
await CurrentAvatar!.TeleportAsync(position, Quaternion.Identity).ConfigureAwait(false);
|
||||
return CurrentWorld!;
|
||||
}
|
||||
|
||||
@ -207,8 +207,8 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
/// <exception cref="TimeoutException">Connection to the world server timed out.</exception>
|
||||
public async Task<VirtualParadiseWorld> EnterAsync(string worldName, Vector3d position, Quaternion rotation)
|
||||
{
|
||||
await EnterAsync(worldName);
|
||||
await CurrentAvatar!.TeleportAsync(position, rotation);
|
||||
await EnterAsync(worldName).ConfigureAwait(false);
|
||||
await CurrentAvatar!.TeleportAsync(position, rotation).ConfigureAwait(false);
|
||||
return CurrentWorld!;
|
||||
}
|
||||
|
||||
@ -226,8 +226,8 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
/// <exception cref="TimeoutException">Connection to the world server timed out.</exception>
|
||||
public async Task EnterAsync(VirtualParadiseWorld world, Vector3d position)
|
||||
{
|
||||
await EnterAsync(world);
|
||||
await CurrentAvatar!.TeleportAsync(position, Quaternion.Identity);
|
||||
await EnterAsync(world).ConfigureAwait(false);
|
||||
await CurrentAvatar!.TeleportAsync(position, Quaternion.Identity).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -245,8 +245,8 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
/// <exception cref="TimeoutException">Connection to the world server timed out.</exception>
|
||||
public async Task EnterAsync(VirtualParadiseWorld world, Vector3d position, Quaternion rotation)
|
||||
{
|
||||
await EnterAsync(world);
|
||||
await CurrentAvatar!.TeleportAsync(position, rotation);
|
||||
await EnterAsync(world).ConfigureAwait(false);
|
||||
await CurrentAvatar!.TeleportAsync(position, rotation).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -263,7 +263,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
public async Task EnterAsync(VirtualParadiseWorld world)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(world);
|
||||
await EnterAsync(world.Name);
|
||||
await EnterAsync(world.Name).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -305,7 +305,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
reason = await _enterCompletionSource.Task;
|
||||
reason = await _enterCompletionSource.Task.ConfigureAwait(false);
|
||||
|
||||
NoSuccess:
|
||||
switch (reason)
|
||||
@ -341,9 +341,9 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
size = vp_int(NativeInstanceHandle, IntegerAttribute.WorldSize);
|
||||
}
|
||||
|
||||
await _worldSettingsCompletionSource.Task;
|
||||
await _worldSettingsCompletionSource.Task.ConfigureAwait(false);
|
||||
|
||||
VirtualParadiseWorld? world = await GetWorldAsync(worldName);
|
||||
VirtualParadiseWorld? world = await GetWorldAsync(worldName).ConfigureAwait(false);
|
||||
if (world is null)
|
||||
{
|
||||
// we entered the world but it wasn't listed. unlisted world. we'll try our best to create details for it
|
||||
@ -496,7 +496,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
reason = await _loginCompletionSource.Task;
|
||||
reason = await _loginCompletionSource.Task.ConfigureAwait(false);
|
||||
NoSuccess:
|
||||
switch (reason)
|
||||
{
|
||||
@ -520,7 +520,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
userId = vp_int(NativeInstanceHandle, IntegerAttribute.MyUserId);
|
||||
}
|
||||
|
||||
CurrentUser = await GetUserAsync(userId);
|
||||
CurrentUser = await GetUserAsync(userId).ConfigureAwait(false);
|
||||
vp_friends_get(NativeInstanceHandle);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user