Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SafelyWaitForLoad< T >()

void ReLogic.Content.AssetRepository.SafelyWaitForLoad< T > ( Asset< T > asset,
Task loadTask,
bool tracked )
inlineprivate
Type Constraints
T :class 

Definition at line 325 of file AssetRepository.cs.

325 : class
326 {
327 if (asset.State == AssetState.Loaded)
328 {
329 return;
330 }
331 if (!loadTask.IsCompleted && IsMainThread)
332 {
333 while (asset.Continuation == null)
334 {
335 Thread.Yield();
336 }
337 if (tracked)
338 {
340 {
341 asset.Continuation();
342 }
343 }
344 else
345 {
346 asset.Continuation();
347 }
348 if (!loadTask.IsCompleted)
349 {
350 throw new Exception("Load task not completed after running continuations on main thread?");
351 }
352 }
353 loadTask.GetAwaiter().GetResult();
354 if (asset.State == AssetState.Loaded)
355 {
356 return;
357 }
358 throw new Exception("How did you get here?");
359 }
static bool Yield()
Definition Thread.cs:412

References ReLogic.Content.AssetRepository._requestLock, ReLogic.Content.AssetRepository.IsMainThread, and System.Threading.Thread.Yield().