private void ResultGetTransferProgressSink(IResourceTransfer transferObject, CpContentDirectory.Enum_A_ARG_TYPE_TransferStatus transferStatus, System.Int64 transferLength, System.Int64 transferTotal, object Tag, UPnPInvokeException error, Exception castError) { label1.Text = (antiblockcount++).ToString(); if (transferLength < 0) { transferProgressLabel.Text = transferTotal + " bytes send"; transferProgressBar.Value = 0; transferProgressBar.Maximum = 100; } else { transferProgressBar.Value = (int)transferTotal; transferProgressBar.Maximum = (int)transferLength; transferProgressLabel.Text = (((double)transferLength / (double)transferTotal) * 100).ToString() + "%"; } stateTextBox.Text = transferStatus.ToString(); if (transferStatus == CpContentDirectory.Enum_A_ARG_TYPE_TransferStatus.IN_PROGRESS) { transferObject.RequestGetTransferProgress(null, new CpMediaDelegates.Delegate_ResultGetTransferProgress(ResultGetTransferProgressSink)); } }
/// <summary> /// This routes execution to the user-provided callback, provided in a call to /// <see cref="ResourceTransfer.RequestGetTransferProgress"/> /// when the results return from <see cref="ResourceTransfer.RequestGetTransferProgress"/>. /// </summary> /// <param name="sender">the <see cref="CpContentDirectory"/> that made the request on the wire</param> /// <param name="TransferID">caller specified ID of the transfer at invoke time</param> /// <param name="TransferStatus">output status for the transfer</param> /// <param name="TransferLength">output progress of the transfer</param> /// <param name="TransferTotal">output expected length of the transfer</param> /// <param name="e">errors reported by media server</param> /// <param name="_Tag"> /// A <see cref="GetTransferProgressRequestTag"/> object that has information about the callback /// and user provided state. /// </param> private void SinkResult_GetTransferProgress(CpContentDirectory sender, System.UInt32 TransferID, CpContentDirectory.Enum_A_ARG_TYPE_TransferStatus TransferStatus, System.String TransferLength, System.String TransferTotal, UPnPInvokeException e, object _Tag) { GetTransferProgressRequestTag rtag = (GetTransferProgressRequestTag)_Tag; if (rtag.Callback != null) { System.Int64 length = -1; System.Int64 total = -1; Exception castError = null; try { System.Int64.Parse(TransferLength); System.Int64.Parse(TransferTotal); } catch (Exception ce) { castError = ce; } rtag.Callback(this, TransferStatus, length, total, rtag.Tag, e, castError); } }