I'm writing a server-client and want to run operation using Task.Run(() => {SomeCode});
this Is my code
Task.Run(() =>
{
_control_com_peer2peer.VerifyConnection(port: 6001, IpAddressClient: ComboBoxRemoteIP.Text);
});
the inner code is basically
public void VerifyConnection(int port, string IpAddressClient)
{
Control_PeerSessionListCheckCreate(RemoteIP: IpAddressClient);
Domain_Peer2PeerCom.peerSessionList.Find(x => x.remoteIP == IpAddressClient).CommandLocker("Hello");
Domain_Peer2PeerCom.PeerSessionChangeIsConnected(IpAddressClient, true);
}
I've break points inside VerifyConnection and none of them fire .
EDIT
entire code for the button firing the Task
private void Connect_Click(object sender, EventArgs e)
{
string s_RemoteIP;
if (ComboBoxRemoteIP.Text != "")
{
if (Network.startPing(ComboBoxRemoteIP.Text))
{
Control_Peer2peerCom.Control_PeerSessionListCheckCreate(ComboBoxRemoteIP.Text);
//bool IspeerReal = Control_Peer2peerCom.peerSessionListGet(ComboBoxRemoteIP.Text, out peerSessionCurrentParam);
if (/*IspeerReal&&*/!(Control_Peer2peerCom.Control_PeerSessionCheckIsConnected(ComboBoxRemoteIP.Text)))//peerSessionCurrentParam.IsConnetcted))//(!Peer2peerCom.isPeerConnetionVerifaied)
{
SelectiveEnable();
tbStatus.Text = "Wait...";
tbStatus.BackColor = Color.Yellow;
s_RemoteIP = ComboBoxRemoteIP.Text;
Task.Run(() =>
{
_control_com_peer2peer.VerifyConnection(port: 6001, IpAddressClient:
ComboBoxRemoteIP.Text);
});
//more code here , Not related
}
of course if I run the method out side of the Task.Run it runs fine
what can be the cause of it
try ... catchinside theTask.Runand check if there is an error.ConsoleorMessageBox?