private void PrivatePush( List<System.IO.FileInfo> files, string destPath )
{
this.TotalItems = files.Count;
if ( this.TotalItems == 0 ) {
this.DialogResult = DialogResult.Cancel;
}
foreach ( var fi in files ) {
this.TotalSize += fi.Length;
}
SpeedTest ( );
SetItemsRemainingStatus ( this.TotalItems.ToString ( ) );
SetCopyInfoLabel ( );
SetTitle ( );
DroidExplorer.Core.Threading.ThreadPool pool = new DroidExplorer.Core.Threading.ThreadPool ( 1 );
foreach ( var fi in files ) {
PushState ps = new PushState ( );
string remotePath = System.IO.Path.Combine ( destPath, fi.Name );
ps.File = fi;
ps.RemotePath = remotePath;
pool.Queue<PushState> ( delegate ( object o ) {
PushState pushState = (PushState)o;
try {
CommandRunner.Instance.PushFile ( pushState.File.FullName, pushState.RemotePath );
if ( this.InvokeRequired ) {
this.Invoke ( new SetFromStatusLabelDelegate ( this.SetFromStatus ), new object[] { Environment.MachineName, ps.File.Name,
CommandRunner.Instance.DefaultDevice, ps.RemotePath } );
this.Invoke ( new SetLabelStatusDelegate ( this.SetItemsRemainingStatus ), new object[] { ( --this.TotalItems ).ToString ( ) } );
} else {
SetFromStatus ( Environment.MachineName, ps.File.Name, CommandRunner.Instance.DefaultDevice, ps.RemotePath );
SetItemsRemainingStatus ( ( --this.TotalItems ).ToString ( ) );
}
} catch ( Exception ex ) {
this.LogError ( ex.Message, ex );
TransferException = ex;
this.DialogResult = DialogResult.Abort;
this.OnTransferError ( EventArgs.Empty );
}
if ( this.TotalItems == 0 ) {
if ( this.InvokeRequired ) {
this.Invoke ( new GenericDelegate ( this.Close ) );
} else {
this.Close ( );
}
this.DialogResult = DialogResult.OK;
this.OnTransferComplete ( EventArgs.Empty );
}
}, ps );
}
SetFromStatus ( Environment.MachineName, files[0].Name, CommandRunner.Instance.DefaultDevice, System.IO.Path.Combine ( destPath, files[0].Name ) );
pool.Start ( );
}