private void PumpAssetLoading() { lock (_syncObj) { if (_internalAssetQueue.Count > 0) { AssetLoadRequest task = _internalAssetQueue.Dequeue(); if (task.UseCustomFunction) { Action handler = null; handler = () => { // ReSharper disable once DelegateSubtraction task.OnDone -= handler; OnTaskCompletedAdd(task); }; task.OnDone += handler; task.Load(); _runningTaskCount++; return; } if (_runningTaskCount == MAXJOBS) { return; } if (task.Block) { task.Load(); while (!task.IsDone) { } task.OnComplete(); } else { QueueUserWorkItem(task); } } } }
public override void Update(float time, float deltaTime) { base.Update(time, deltaTime); // we have completed lets pump the asset queue again! PumpAssetLoading(); while (_internalCompletedQueue.Count != 0) { AssetLoadRequest cpTask = _internalCompletedQueue.Dequeue(); if (cpTask.HasFailed) { cpTask.OnFailure(); } else { cpTask.OnComplete(); } } }