private void AddStringToView(TimerParams timerParameters, string ThreadString) { var item = new ListViewItem(new[] { timerParameters.timerID, ThreadString }); if (timerParameters.listView.InvokeRequired) { timerParameters.listView.Invoke(new MethodInvoker(delegate { if (timerParameters.listView.Items.Count > 20) { timerParameters.listView.Items.RemoveAt(0); } timerParameters.listView.Items.Add(item); item.Checked = true; })); } else { if (timerParameters.listView.Items.Count > 20) { timerParameters.listView.Items.RemoveAt(0); } timerParameters.listView.Items.Add(item); item.Checked = true; } }
public void AddDataToMdbFile(TimerParams timerparams, string ThreadGeneratedData) { object obj = new object(); string addquery = string.Format("INSERT INTO ThreadData(ThreadID, [Time], Data) VALUES('{0}', '{1}', '{2}');", timerparams.timerID, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"), ThreadGeneratedData ); con.Execute(addquery, out obj, 0); }
public void TimerEventProcessor(object timerParameters) { TimerParams timerparams = (TimerParams)timerParameters; int NumberOfGeneratedSymbols = StaticRandom.Rand(MinLineLengh, MaxLineLengh); string ThreadGeneratedData = ""; for (int i = 0; i < NumberOfGeneratedSymbols; i++) { ThreadGeneratedData += (char)(StaticRandom.Rand(FirstASCIICharacter, LastASCIICharacter)); } AddStringToView(timerparams, ThreadGeneratedData); accessdatabase.AddDataToMdbFile(timerparams, ThreadGeneratedData); int RandomInterval = StaticRandom.Rand(MinInterval, MaxInterval); if (_threads.Count > 0) { _threads[timerparams.timerID].Change(RandomInterval, 0); } }