throw more cancellationtokens around
This commit is contained in:
@@ -607,18 +607,24 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
ActionQueue.Enqueue(action);
|
ActionQueue.Enqueue(action);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!fireAndForget)
|
if (!fireAndForget)
|
||||||
{
|
{
|
||||||
var disposeToken = _disposalCts.Token;
|
var disposeToken = _disposalCts.Token;
|
||||||
var combinedToken = CancellationTokenSource.CreateLinkedTokenSource(disposeToken, token).Token;
|
var combinedToken = CancellationTokenSource.CreateLinkedTokenSource(disposeToken, token).Token;
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
|
await Task.Delay(TimeSpan.FromSeconds(1), combinedToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!combinedToken.IsCancellationRequested)
|
if (!combinedToken.IsCancellationRequested)
|
||||||
await _dalamudUtil.WaitWhileCharacterIsDrawing(logger, obj, applicationId, 30000, combinedToken).ConfigureAwait(false);
|
await _dalamudUtil.WaitWhileCharacterIsDrawing(logger, obj, applicationId, 30000, combinedToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
_penumbraRedrawRequests[obj.Address] = false;
|
_penumbraRedrawRequests[obj.Address] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mediator.Publish(new PenumbraEndRedrawMessage(obj.Address));
|
Mediator.Publish(new PenumbraEndRedrawMessage(obj.Address));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase
|
|||||||
{
|
{
|
||||||
if (PlayerCharacter == IntPtr.Zero) return;
|
if (PlayerCharacter == IntPtr.Zero) return;
|
||||||
var ptr = PlayerCharacter;
|
var ptr = PlayerCharacter;
|
||||||
|
|
||||||
var handler = changes.Key switch
|
var handler = changes.Key switch
|
||||||
{
|
{
|
||||||
ObjectKind.Player => _charaHandler!,
|
ObjectKind.Player => _charaHandler!,
|
||||||
@@ -202,14 +203,16 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase
|
|||||||
_ => throw new NotSupportedException("ObjectKind not supported: " + changes.Key)
|
_ => throw new NotSupportedException("ObjectKind not supported: " + changes.Key)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (handler.Address == IntPtr.Zero)
|
if (handler.Address == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (handler != _charaHandler) handler.Dispose();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.LogDebug("[{applicationId}] Applying Customization Data for {handler}", applicationId, handler);
|
Logger.LogDebug("[{applicationId}] Applying Customization Data for {handler}", applicationId, handler);
|
||||||
await _dalamudUtil.WaitWhileCharacterIsDrawing(Logger, handler, applicationId, 30000).ConfigureAwait(false);
|
await _dalamudUtil.WaitWhileCharacterIsDrawing(Logger, handler, applicationId, 30000, token).ConfigureAwait(false);
|
||||||
|
token.ThrowIfCancellationRequested();
|
||||||
foreach (var change in changes.Value)
|
foreach (var change in changes.Value)
|
||||||
{
|
{
|
||||||
Logger.LogDebug("[{applicationId}] Processing {change} for {handler}", applicationId, change, handler);
|
Logger.LogDebug("[{applicationId}] Processing {change} for {handler}", applicationId, change, handler);
|
||||||
@@ -238,10 +241,14 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
token.ThrowIfCancellationRequested();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
if (handler != _charaHandler) handler.Dispose();
|
if (handler != _charaHandler) handler.Dispose();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Dictionary<ObjectKind, HashSet<PlayerChanges>> CheckUpdatedData(CharacterData oldData, CharacterData newData, bool forced)
|
private Dictionary<ObjectKind, HashSet<PlayerChanges>> CheckUpdatedData(CharacterData oldData, CharacterData newData, bool forced)
|
||||||
{
|
{
|
||||||
@@ -382,14 +389,14 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((!_applicationTask?.IsCompleted ?? false) && !downloadToken.IsCancellationRequested)
|
while ((!_applicationTask?.IsCompleted ?? false) && !downloadToken.IsCancellationRequested && !_applicationCancellationTokenSource.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
// block until current application is done
|
// block until current application is done
|
||||||
Logger.LogDebug("Waiting for current data application (Id: {id}) to finish", _applicationId);
|
Logger.LogDebug("Waiting for current data application (Id: {id}) to finish", _applicationId);
|
||||||
await Task.Delay(250).ConfigureAwait(false);
|
await Task.Delay(250).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downloadToken.IsCancellationRequested) return;
|
if (downloadToken.IsCancellationRequested || _applicationCancellationTokenSource.IsCancellationRequested) return;
|
||||||
|
|
||||||
_applicationCancellationTokenSource?.Dispose();
|
_applicationCancellationTokenSource?.Dispose();
|
||||||
_applicationCancellationTokenSource = new();
|
_applicationCancellationTokenSource = new();
|
||||||
|
|||||||
Reference in New Issue
Block a user