/// <summary> /// Thread that calls a Method of the server-side Class TPollClientTasks in /// regular intervals. /// /// @comment The Thread is started at Class instantiation and can be stopped by /// calling the StopKeepAlive method. /// /// @comment The interval can be configured with the ClientSetting /// 'ServerPollIntervalInSeconds'. /// /// </summary> /// <returns>void</returns> public void PollClientTasksThread() { DataTable ClientTasksDataTable; TClientTasksQueue ClientTasksQueueInstance; Thread ClientTaskQueueThread; // Check whether this Thread should still execute while (FKeepPollingClientTasks) { try { // Make PollClientTasks call to Server to keep the Client's remoted objects // and it's AppDomain alive. // The value of the AClientTasksDataTable parameter is always null, except when // the Server has a queued ClientTask that the Client needs to read. ClientTasksDataTable = FRemotePollClientTasks.PollClientTasks(); if (ClientTasksDataTable != null) { // MessageBox.Show('Client Tasks Table has ' + (ClientTasksDataTable.Rows.Count).ToString + ' entries!'); // Queue new ClientTasks and execute them. // This is done in a separate Thread to make sure the PollClientTasks thread can run // without the risk of being interrupted! ClientTasksQueueInstance = new TClientTasksQueue(FClientID, ClientTasksDataTable); ClientTaskQueueThread = new Thread(new ThreadStart(ClientTasksQueueInstance.QueueClientTasks)); ClientTaskQueueThread.Start(); } } catch (System.Runtime.Remoting.RemotingException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionBroken + DebugInfo, AppCoreResourcestrings.StrConnectionBrokenTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("RemotingException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (System.Net.Sockets.SocketException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString() + "\r\n\r\nSocketException.ErrorCode: " + Exp.ErrorCode.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionClosed + DebugInfo, AppCoreResourcestrings.StrConnectionClosedTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("SocketException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (Exception Exp) { TLogging.Log("Exception in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } // Sleep for some time. After that, this function is called again automatically. Thread.Sleep(TClientSettings.ServerPollIntervalInSeconds * 1000); } // Thread stops here and doesn't get called again automatically. }
/// <summary> /// Thread that calls a Method of the server-side Class TPollClientTasks in /// regular intervals. /// /// @comment The Thread is started at Class instantiation and can be stopped by /// calling the StopKeepAlive method. /// /// @comment The interval can be configured with the ClientSetting /// 'ServerPollIntervalInSeconds'. /// /// </summary> /// <returns>void</returns> public void PollClientTasksThread() { DataTable ClientTasksDataTable; TClientTasksQueue ClientTasksQueueInstance; // Check whether this Thread should still execute while (FKeepPollingClientTasks) { try { // Make PollClientTasks call to Server to keep the Client's remoted objects // and its AppDomain alive. // The value of the AClientTasksDataTable parameter is always null, except when // the Server has a queued ClientTask that the Client needs to read. ClientTasksDataTable = RemotePollClientTasks(); if (ClientTasksDataTable != null) { TLogging.LogAtLevel(4, "Client Tasks Table has " + ClientTasksDataTable.Rows.Count.ToString() + " entries!"); // Queue new ClientTasks and execute them. ClientTasksQueueInstance = new TClientTasksQueue(FClientID, ClientTasksDataTable); // This is done in a separate Thread to make sure the PollClientTasks thread can continue to run // without the risk of being interrupted in case the execution of (a) ClientTask(s) takes some time! Thread ClientTaskQueueThread = new Thread(new ThreadStart(ClientTasksQueueInstance.QueueClientTasks)); ClientTaskQueueThread.Name = String.Format("ClientID_{0}__ClientTasksQueueThread", FClientID); TLogging.LogAtLevel(7, ClientTaskQueueThread.Name + "starting."); ClientTaskQueueThread.SetApartmentState(ApartmentState.STA); ClientTaskQueueThread.Start(); } } catch (System.Runtime.Remoting.RemotingException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionBroken + DebugInfo, AppCoreResourcestrings.StrConnectionBrokenTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("RemotingException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (System.Net.Sockets.SocketException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString() + "\r\n\r\nSocketException.ErrorCode: " + Exp.ErrorCode.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionClosed + DebugInfo, AppCoreResourcestrings.StrConnectionClosedTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("SocketException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (Exception Exp) { TLogging.Log("Exception in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); if (Exp.Message == THTTPUtils.SESSION_ALREADY_CLOSED) { // TODORemoting close the client TLogging.Log("TPollClientTasks: Should have closed the Client here!!!"); return; } } // Sleep for some time. After that, this function is called again automatically. TLogging.LogAtLevel(10, "PollClientTasks sleeping for " + TClientSettings.ServerPollIntervalInSeconds + " seconds"); Thread.Sleep(TimeSpan.FromSeconds(TClientSettings.ServerPollIntervalInSeconds)); } // Thread stops here and doesn't get called again automatically. }
/// <summary> /// Thread that calls a Method of the server-side Class TPollClientTasks in /// regular intervals. /// /// @comment The Thread is started at Class instantiation and can be stopped by /// calling the StopKeepAlive method. /// /// @comment The interval can be configured with the ClientSetting /// 'ServerPollIntervalInSeconds'. /// /// </summary> /// <returns>void</returns> public void PollClientTasksThread() { DataTable ClientTasksDataTable; TClientTasksQueue ClientTasksQueueInstance; Thread ClientTaskQueueThread; // Check whether this Thread should still execute while (FKeepPollingClientTasks) { try { // Make PollClientTasks call to Server to keep the Client's remoted objects // and it's AppDomain alive. // The value of the AClientTasksDataTable parameter is always null, except when // the Server has a queued ClientTask that the Client needs to read. ClientTasksDataTable = FRemotePollClientTasks.PollClientTasks(); if (ClientTasksDataTable != null) { // MessageBox.Show('Client Tasks Table has ' + (ClientTasksDataTable.Rows.Count).ToString + ' entries!'); // Queue new ClientTasks and execute them. // This is done in a separate Thread to make sure the PollClientTasks thread can run // without the risk of being interrupted! ClientTasksQueueInstance = new TClientTasksQueue(FClientID, ClientTasksDataTable); ClientTaskQueueThread = new Thread(new ThreadStart(ClientTasksQueueInstance.QueueClientTasks)); ClientTaskQueueThread.Start(); } } catch (System.Runtime.Remoting.RemotingException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionBroken + DebugInfo, AppCoreResourcestrings.StrConnectionBrokenTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("RemotingException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (System.Net.Sockets.SocketException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString() + "\r\n\r\nSocketException.ErrorCode: " + Exp.ErrorCode.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionClosed + DebugInfo, AppCoreResourcestrings.StrConnectionClosedTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("SocketException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (Exception Exp) { TLogging.Log("Exception in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } // Sleep for some time. After that, this function is called again automatically. Thread.Sleep(TClientSettings.ServerPollIntervalInSeconds * 1000); } // Thread stops here and doesn't get called again automatically. }
/// <summary> /// Thread that calls a Method of the server-side Class TPollClientTasks in /// regular intervals. /// /// @comment The Thread is started at Class instantiation and can be stopped by /// calling the StopKeepAlive method. /// /// @comment The interval can be configured with the ClientSetting /// 'ServerPollIntervalInSeconds'. /// /// </summary> /// <returns>void</returns> public void PollClientTasksThread() { DataTable ClientTasksDataTable; TClientTasksQueue ClientTasksQueueInstance; // Check whether this Thread should still execute while (FKeepPollingClientTasks) { try { // Make PollClientTasks call to Server to keep the Client's remoted objects // and it's AppDomain alive. // The value of the AClientTasksDataTable parameter is always null, except when // the Server has a queued ClientTask that the Client needs to read. ClientTasksDataTable = RemotePollClientTasks(); if (ClientTasksDataTable != null) { TLogging.LogAtLevel(4, "Client Tasks Table has " + ClientTasksDataTable.Rows.Count.ToString() + " entries!"); // Queue new ClientTasks and execute them. ClientTasksQueueInstance = new TClientTasksQueue(FClientID, ClientTasksDataTable); ClientTasksQueueInstance.QueueClientTasks(); /* * // This is done in a separate Thread to make sure the PollClientTasks thread can run * // without the risk of being interrupted! * * Thread ClientTaskQueueThread = new Thread(new ThreadStart(ClientTasksQueueInstance.QueueClientTasks)); * ClientTaskQueueThread.Start(); */ } } catch (System.Runtime.Remoting.RemotingException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionBroken + DebugInfo, AppCoreResourcestrings.StrConnectionBrokenTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("RemotingException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (System.Net.Sockets.SocketException Exp) { // string DebugInfo = StrConnectionUnavailableCause + Exp.ToString() + "\r\n\r\nSocketException.ErrorCode: " + Exp.ErrorCode.ToString(); // MessageBox.Show(AppCoreResourcestrings.StrConnectionClosed + DebugInfo, AppCoreResourcestrings.StrConnectionClosedTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); TLogging.Log("SocketException in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); } catch (Exception Exp) { TLogging.Log("Exception in TPollClientTasks.PollClientTasksThread: " + Exp.ToString(), TLoggingType.ToLogfile); if (Exp.Message == THTTPUtils.SESSION_ALREADY_CLOSED) { // TODORemoting close the client TLogging.Log("TPollClientTasks: Should have closed the Client here!!!"); return; } } // Sleep for some time. After that, this function is called again automatically. TLogging.LogAtLevel(10, "PollClientTasks sleeping for " + TClientSettings.ServerPollIntervalInSeconds + " seconds"); Thread.Sleep(TimeSpan.FromSeconds(TClientSettings.ServerPollIntervalInSeconds)); } // Thread stops here and doesn't get called again automatically. }