Example #1
0
 private static void DownloadTestsXap(Uri testsXapUri, Action<StreamResourceInfo> OnDownloadComplete)
 {
     _onDownloadComplete = OnDownloadComplete;
     WebClient wc = new WebClient();
     wc.OpenReadCompleted += new OpenReadCompletedEventHandler(DownloadTestXap_Complete);
     wc.OpenReadAsync(testsXapUri);
 }
Example #2
0
 public void Play(string filename, int song)
 {
     Filename = filename;
     Song = song;
     WebClient = new WebClient();
     WebClient.OpenReadCompleted += WebClient_OpenReadCompleted;
     WebClient.OpenReadAsync(new Uri(filename, UriKind.Relative));
 }
Example #3
0
    public void GetVersionAsynch(string version,string token, string fullpath,bool test)
    {
        //string file = null;
            string URL = "http://moscrif.com/ide/getVersion.ashx?v={0}";
            client = new WebClient();

            client.DownloadProgressChanged+= delegate(object sender, DownloadProgressChangedEventArgs e) {

                //Console.WriteLine("----> {0}",e.ProgressPercentage);;
                /*progressBar.Text = e.ProgressPercentage.ToString();
                progressBar.QueueDraw();

                while (Application.EventsPending ())
                    Application.RunIteration ();*/
            };

            if(String.IsNullOrEmpty(token)){
                URL = String.Format(URL,version);
            } else {
                URL = String.Format(URL+"&t={1}",version,token);
            }

            //URL = String.Format(URL,version,token);

            if(test){
                URL = URL+"&test=1";
            }

            Console.WriteLine("URL ->{0}",URL);

            //client.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e) {   //OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e) {//UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
            client.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e) {//UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
                if (e.Cancelled){
                    isFinish = true;
                    return;
                }

                if (e.Error != null){
                    isFinish = true;
                    return;
                }

                if(File.Exists(fullpath))
                    File.Delete(fullpath);

                FileStream writeStream = new FileStream(fullpath, FileMode.Create, FileAccess.Write);
                try{
                    Copy(e.Result,writeStream);
                    writeStream.Close();
                    writeStream.Dispose();
                }catch{
                    isError = true;
                }
                isFinish = true;
            };
            client.OpenReadAsync(new Uri(URL));
            //client.DownloadStringAsync(new Uri(URL));

        //	while (Application.EventsPending ())
        //		Application.RunIteration ();
    }