WebClient.UploadProgressChanged

AleAle ITMember

Hi,

I implementing a communication method for my app using WebClient.UploadDataAsync but event UploadProgressChanged is never raised.
UploadDataCompleted event work well.

`private void Verifica(byte[] img, byte[] img2, byte[] imgCode, string lang, string udid, double lat, double lon)

    {

        System.Net.WebClient client = new System.Net.WebClient ();



        SixTrue.Engine.Data.RichiestaVerifica request = new SixTrue.Engine.Data.RichiestaVerifica()

        {

            immagine = img.ToList(),

            immagine2 = img.ToList(),//new List<byte>(),

            codiceimmagine = imgCode.ToList(),

            udid = udid,

            codicelingua = lang,

            latitudine = (decimal)lat,

            longitudine = (decimal)lon,

            username = ""//user

        };



        string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(request);



        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding ();

        Uri url = new Uri(String.Format("{0}/VerificaAdv", "http://www.website.net/Service.svc"));

        client.Headers[System.Net.HttpRequestHeader.ContentType] = "application/json";



        client.UploadProgressChanged += (object sender, System.Net.UploadProgressChangedEventArgs e) => {

            System.Diagnostics.Debug.WriteLine("progress");

        };



        client.UploadDataCompleted += (object sender, System.Net.UploadDataCompletedEventArgs e) => {

            System.Diagnostics.Debug.WriteLine("completed");

        };



        client.UploadDataAsync(url, encoding.GetBytes(requestJson));



        System.Diagnostics.Debug.WriteLine ("Started");

}`

Thanks,
Alessandro

Sign In or Register to comment.