private void OnAsyncProgressChanged(object sender, AsyncPixelDataProgressEventArgs e)
 {
     if (_delayedEventPublisher != null)
     {
         _delayedEventPublisher.Publish(sender, e);
     }
 }
예제 #2
0
            private void UpdateProgress(int progressPercent, bool isComplete, byte[] pixelData, Exception faultException, bool fireEvents)
            {
                if (!isComplete && progressPercent == ProgressPercent)
                {
                    return;                     // ignore this update request if progress hasn't changed and we're not notifying that loading is complete
                }
                ProgressPercent = Math.Min(100, Math.Max(0, progressPercent));
                IsLoaded        = isComplete;
                IsFaulted       = isComplete && faultException != null;

                lock (SyncLock)
                {
                    // setting the exception needs to be synchronized with the GetNormalizedPixelData method because that's where we check it
                    _lastAsyncException = faultException;
                }

                if (!fireEvents)
                {
                    return;
                }

                lock (_progressEventSyncLock)
                {
                    var e = new AsyncPixelDataProgressEventArgs(progressPercent, isComplete, pixelData);
                    EventsHelper.Fire(_progressChanged, this, e);
                    if (isComplete)
                    {
                        EventsHelper.Fire(_loaded, this, e);
                    }
                    if (isComplete && faultException != null)
                    {
                        EventsHelper.Fire(_faulted, this, new AsyncPixelDataFaultEventArgs(pixelData, faultException));
                    }
                }
            }
		private void OnAsyncProgressChanged(object sender, AsyncPixelDataProgressEventArgs e)
		{
			if (_delayedEventPublisher != null)
				_delayedEventPublisher.Publish(sender, e);
		}
예제 #4
0
			private void UpdateProgress(int progressPercent, bool isComplete, byte[] pixelData, Exception faultException, bool fireEvents)
			{
				if (!isComplete && progressPercent == ProgressPercent)
					return; // ignore this update request if progress hasn't changed and we're not notifying that loading is complete

				ProgressPercent = Math.Min(100, Math.Max(0, progressPercent));
				IsLoaded = isComplete;
				IsFaulted = isComplete && faultException != null;

				lock (SyncLock)
				{
					// setting the exception needs to be synchronized with the GetNormalizedPixelData method because that's where we check it
					_lastAsyncException = faultException;
				}

				if (!fireEvents)
					return;

				lock (_progressEventSyncLock)
				{
					var e = new AsyncPixelDataProgressEventArgs(progressPercent, isComplete, pixelData);
					EventsHelper.Fire(_progressChanged, this, e);
					if (isComplete) EventsHelper.Fire(_loaded, this, e);
					if (isComplete && faultException != null) EventsHelper.Fire(_faulted, this, new AsyncPixelDataFaultEventArgs(pixelData, faultException));
				}
			}