private void wclient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() => {
         if (_waiting.ContainsKey((WebClient)sender))
         {
             ActionDownloadFileArg arg = _waiting[(WebClient)sender];
             try {
                 var streamResourceInfo      = new StreamResourceInfo(e.Result, null);
                 var userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication();
                 if (userStoreForApplication.FileExists(arg.FileSaveName))
                 {
                     userStoreForApplication.DeleteFile(arg.FileSaveName);
                 }
                 using (IsolatedStorageFileStream isolatedStorageFileStream = userStoreForApplication.CreateFile(arg.FileSaveName)){
                     var buf       = new byte[1024];
                     int readcount = 0;
                     while ((readcount = streamResourceInfo.Stream.Read(buf, 0, buf.Length)) != 0)
                     {
                         isolatedStorageFileStream.Write(buf, 0, readcount);
                     }
                 }
                 Done(arg);
             }  catch (Exception ex) {
                 Cancel(arg);
             }
         }
     });
 }
        void download(ActionDownloadFileArg arg)
        {
            WebClient wclient = new WebClient();

            _waiting.Add(wclient, arg);
            wclient.OpenReadCompleted += wclient_OpenReadCompleted;
            wclient.OpenReadAsync(new Uri(arg.FileUrl, UriKind.Absolute));
        }
        public override bool precheckToDo(ActionArgs e)
        {
            ActionDownloadFileArg arg = e as ActionDownloadFileArg;

            return(arg != null && arg.FileUrl.Length > 0 && arg.FileSaveName.Length > 0);
        }