From: <br...@us...> - 2008-06-23 11:46:45
|
Revision: 278 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=278&view=rev Author: brus07 Date: 2008-06-23 04:44:43 -0700 (Mon, 23 Jun 2008) Log Message: ----------- Automatic set current IP to textBox. Modified Paths: -------------- ACMServer/trunk/ACMServer/Tester/Form1.cs Modified: ACMServer/trunk/ACMServer/Tester/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-06-22 23:19:59 UTC (rev 277) +++ ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-06-23 11:44:43 UTC (rev 278) @@ -18,6 +18,9 @@ public Form1() { InitializeComponent(); + + string ip = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString(); + textBox3.Text = ip; } private void button1_Click(object sender, EventArgs e) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-07-06 20:49:46
|
Revision: 291 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=291&view=rev Author: brus07 Date: 2008-07-06 13:49:54 -0700 (Sun, 06 Jul 2008) Log Message: ----------- Tester don't wait testing for receive new data via socket. Tester don't calculate new data when working on old data (in future response to Mediator about state). Modified Paths: -------------- ACMServer/trunk/ACMServer/Tester/Form1.cs Modified: ACMServer/trunk/ACMServer/Tester/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-07-06 16:42:12 UTC (rev 290) +++ ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-07-06 20:49:54 UTC (rev 291) @@ -8,12 +8,13 @@ using AcmContester.Library.Connector; using System.IO; using AcmContester.Library.LibraryExtention; +using System.Threading; namespace Tester { public partial class Form1 : Form { - SocketClient socket; + static SocketClient socket; public Form1() { @@ -56,10 +57,44 @@ } private void DataArrived(string message) { - string result = ""; - UpdateTextLog("\r\n" + message); + AddWork(message); + } + static string source; + static object working = 0; + Thread thread = new Thread(new ThreadStart(Go)); + void AddWork(string message) + { + lock (working) + { + if ((int)working == 1 || (thread.ThreadState == ThreadState.Running)) + { + UpdateTextLog("\r\n--------- busy ---------"); + return; + } + } + source = message; + onDataArrived += UpdateTextLog; + thread = new Thread(new ThreadStart(Go)); + thread.Start(); + } + + static void Go() + { + lock (working) + { + working = 1; + } + Testing(source); + lock (working) + { + working = 0; + } + } + static void Testing(string message) + { + string result; try { result = Checker.Checker.GetResult(message); @@ -72,11 +107,19 @@ return; } - UpdateTextLog("\r\n" + result); - socket.Send(result); + if (onDataArrived != null) + { + onDataArrived("\r\n" + result); + onDataArrived("\r\n--------- free ---------"); + } + //UpdateTextLog("\r\n" + result); + lock(socket) + socket.Send(result); } + public delegate void DataArrivedDelegate(string s); + public static event DataArrivedDelegate onDataArrived; delegate void UpdateTextLogCallback(string message); private void UpdateTextLog(string message) @@ -98,6 +141,7 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e) { + thread.Abort(); Disconnect(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |