c# - Global Variable not incrementing on callback functions -


After

I am using Webclient to upload data to a server using Async calls,

  WebClient WebClient = new webclient (); WebClient.UploadDataAsync (Yuri, "Pt", Buffer, UserToken);  

I have linked datepload progress and data uploads related events to the appropriate callback function

  // Full webmail uploaded. Upload Data Contains + = New UploadData Provisioning Handler (UploadDataCallback2); // uploaded progress webClient.UploadProgressChanged + = new uploadprogressingthan handler (uploadprogelbackback);  

And in the function I am trying to show some message boxes:

  // upgrade date progress zero upload progress callback (object sender, Upgrade Progress Changed Event ARG E) {Show the message box (this, "upload progress, x =" + x); X ++; MessageBox.Show (e.BytesSent.ToString ()); } // Full UploadDataCallBlack2 (Object Sender, UploadDataCompletedEventArgsE) on uploaded date {MessageBox.Show (this, "uploaded, x =" + x); X ++; MessageBox.Show (ASCIIEncoding.UTF8.GetString (e.Result)); }  

Where x is a global variable, but for some reasons X does not grow, and all message boxes show X = 0.

Anyone The explanation is very much appreciated ..

Oh problem, well apparently the problem is a 2- Parts were a problem, and I hope someone will confirm my conclusion:

  • Message boxes in progress. Show off, blocking the work with progress, resulting in x pressed OK till zero.
  • The file I was uploading was very small, so the data upload event was called before I clicked on the message box right from the progress event Got enough time for

  • Comments

    Popular posts from this blog

    oracle - The fastest way to check if some records in a database table? -

    php - multilevel menu with multilevel array -

    jQuery UI: Datepicker month format -