I am Transfer file from Client to server using Socket Programming asynchronously. But I want to bind datagridview control after completion of running task.
I have form with Client list in left corner and in the remaining form i am showing the selected client file list (selected client from left corner) , when i am File transfer from client to server it was transferred properly and immediately bind this transferred file to right corner DataGridView control With File Name and Path from async method issue start here at time i can not bind this grid control.
Thanks in Advance.....
Below is my Code :
public void collectFileFromClientSocket(string ClientIpAddr, string clientLogDir)
{
try
{
Task task ;
var cts = new CancellationTokenSource();
ServerSideSocketProgramming serversocketProg = new ServerSideSocketProgramming();
ModFunctions modFunc = new ModFunctions();
Common.ModWipeOut modWipeOut = new Common.ModWipeOut();
RegistryKey regKey = modFunc.DefineRegistryKey(Common.ModWipeOut.WipeOutRegistryPATH, false);
int port = int.Parse(modWipeOut.Decrypt(modFunc.ReadRegistry(modWipeOut.Encrypt(Common.ModWipeOut.PortNumber), regKey)));//
string logCommonFolder = modFunc.ReadRegistry(Common.ModWipeOut.LogReportFolderPath, regKey);// @"E:\";
string CreateLocalSysIPDirOnServer = logCommonFolder + "\\";
if (!Directory.Exists(CreateLocalSysIPDirOnServer))
Directory.CreateDirectory(CreateLocalSysIPDirOnServer);
// Call Client from IP Address
serversocketProg.CallClient(ClientIpAddr, port);
//Transferring file from Client to Server
Task.Factory.StartNew(() => serversocketProg.HandleIncomingFile(port, CreateLocalSysIPDirOnServer)
).ContinueWith(t=>
//Fill the DataGridView Method, but not bind the DataGridView control
fillLogFileInGrid(clientLogDir));
}
catch (Exception ex)
{
//MessageBox.Show(ex.ToString());
}
}