Remoting Timeout
Hej,Jeg laver remoting (med hjælp fra Arne) i et projekt. I den forbindelse, tester jeg forbindelsen og her løber jeg en i problemer.
Jeg vil frygtelig gerne sætte timeout tiden ned fra det ca. 1 minut den tager om at svare til noget mere passende. Men af en eller anden grund så er den ligeglad med jeg sætter timeout på. Kan nogen se i min TestConnection metode, hvad jeg gør forkert?
void TestConnection(object o)
{
if (InvokeRequired)
{
object[] ob = (object[])o;
string host = (string)ob[0];
string port = (string)ob[1];
string toReturn = "";
System.Collections.IDictionary properties = new System.Collections.Hashtable();
//properties["connectionTimeout"] = 1 * 1000;
properties["timeout"] = 1 * 1000;
TcpClientChannel myTcpClientChanel = new TcpClientChannel(properties, null);
try
{
ChannelServices.RegisterChannel(myTcpClientChanel, false);
IConnectionService connection = (IConnectionService)Activator.GetObject(typeof(IConnectionService), "tcp://" + host + ":" + port + "/Connection");
toReturn = connection.GetConnection();
}
catch (SocketException se)
{
toReturn = "Der kunne ikke oprettes forbindelse til serveren.\r\n" + se.Message.ToString();
}
catch (Exception ex)
{
toReturn = "Der opstod en uhåndteret fejl.\r\n" + ex.Message.ToString();
}
finally
{
if (myTcpClientChanel != null)
{
ChannelServices.UnregisterChannel(myTcpClientChanel);
}
}
this.BeginInvoke(new WaitCallback(TestConnection), toReturn);
}
else
{
//set cursor to normal
string message = (string)o;
this.btnCancel.Enabled = true;
this.btnOK.Enabled = true;
this.Cursor = Cursors.Default;
MessageBox.Show(message);
}
return;
}
mvh
simsen :-)