Skip to content

Commit

Permalink
AsyncJob implementations must be completely initialized when they reg…
Browse files Browse the repository at this point in the history
…ister to AsyncJobManager
  • Loading branch information
azuisleet committed Nov 6, 2020
1 parent 117265d commit cf3f91b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions SteamKit2/SteamKit2/Steam/SteamClient/AsyncJobManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void StartJob( AsyncJob asyncJob )
{
asyncJobs.TryAdd( asyncJob, asyncJob );
}

/// <summary>
/// Passes a callback to a pending async job.
/// If the given callback completes the job, the job is removed from this manager.
Expand Down
14 changes: 13 additions & 1 deletion SteamKit2/SteamKit2/Types/JobID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,17 @@ internal AsyncJob( SteamClient client, JobID jobId )
jobStart = DateTime.UtcNow;
JobID = jobId;

client.StartJob( this );

}

/// <summary>
/// Constructors are required to register this AsyncJob with the JobManager once initialized.
/// </summary>
/// <param name="client"></param>
internal void RegisterJob( SteamClient client )
{
client.StartJob( this );
}

/// <summary>
/// Adds a callback to the async job's result set.
Expand Down Expand Up @@ -178,6 +186,8 @@ public AsyncJob( SteamClient client, JobID jobId )
: base( client, jobId )
{
tcs = new TaskCompletionSource<T>( TaskCreationOptions.RunContinuationsAsynchronously );

RegisterJob( client );
}


Expand Down Expand Up @@ -290,6 +300,8 @@ public AsyncJobMultiple( SteamClient client, JobID jobId, Predicate<T> finishCon
tcs = new TaskCompletionSource<ResultSet>( TaskCreationOptions.RunContinuationsAsynchronously );

this.finishCondition = finishCondition;

RegisterJob( client );
}


Expand Down

0 comments on commit cf3f91b

Please sign in to comment.