Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   How to have the cancel button enabled during an upload process (http://www.go4expert.com/forums/cancel-button-enabled-upload-process-t1889/)

Leo 14Nov2006 15:43

How to have the cancel button enabled during an upload process
 
Actually my aim to enable a cancel button while this upload takes place.I tried raising an event which makes the cancel button enabled while the upload process is going on.

But I am not able to click on the cancel button, i dont get the access to click it.Once the process is completed i am able to click the button to generate the event.

Does any one know how this can be done in C#(Windows application)

Sample code is :
Code:

while (bytesRead > 0)
{

if (iteration == 1)
this._startTime = DateTime.Now;

bytesWritten = this._workFlowProxy.UploadChunk(this._taskId, buffer, sentBytes, bytesRead);
if (iteration == LoadManagerConstants.AverageSample + 1) //AverageSample = 5
{
timeForInitialChunks = (long)DateTime.Now.Subtract(this._startTime).TotalMilliseconds;
averageChunkTime = System.Math.Max
(1, timeForInitialChunks / LoadManagerConstants.AverageSample);

//Maximum size that can be uploaded at a time cannot be more than 4KB
chunkSize = (int)System.Math.Min(LoadManagerConstants.MaxFileSize,
chunkSize * preferredTransferDuration / averageChunkTime);

buffer = new byte[chunkSize];
}
sentBytes += bytesRead;
percentageOfTotalSize = (int)(((decimal)sentBytes / (decimal)fileSize) * 100);
this.SetProgressStatus(percentageOfTotalSize);
bytesRead = fileToUpLoad.Read(buffer, LoadManagerConstants.Offset, chunkSize);
iteration++;
}


shabbir 14Nov2006 20:26

Re: How to have the cancel button enabled during an upload process
 
Refer to thread How to enable a cancel button when an upload takes place.


All times are GMT +5.5. The time now is 07:25.