111,075
社区成员




public void ConnectToSSID()
{
string str1 = System.IO.Directory.GetCurrentDirectory();
Process proc = null;
try
{
LogHelper.WriteLog(0, "正在执行网络重启");
string targetDir = string.Format(@".\config");//this is where mybatch.bat lies
proc = new Process();
proc.StartInfo.WorkingDirectory = targetDir;
proc.StartInfo.FileName = "connectWifi.bat";
proc.StartInfo.Arguments = string.Format("10");//this is argument
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
LogHelper.WriteLog(0, "网络重启完成");
}
catch (Exception ex)
{
//Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
throw;
}
}
private void LogerWatch()
{
while(flag_Form)
{
if (!this.IsHandleCreated || this.IsDisposed)
{
continue;
}
else
{
flag_Form = false;
}
}
while (logWatching && !flag_Form)
{
LoggingEvent[] events = appender.GetEvents();
this.wifi_Quality_ProgressBar.BeginInvoke(uPB_CallBack, (int)wifiso.CurrentWifiQuality);
this.wifi_Quality_Label.BeginInvoke(uL_CallBack, ("信号强度:"+(int)wifiso.CurrentWifiQuality).ToString());
if (events != null && events.Length > 0)
{
// if there are events, we clear them from the logger,
// since we're done with them
appender.Clear();
foreach (LoggingEvent ev in events)
{
//string line = ev.LoggerName + ": " + ev.RenderedMessage + "\r\n";
string line = ev.RenderedMessage + "\r\n";
AppendLog(line);
}
}
Thread.Sleep(1000);
}
}
private void AppendLog(string line)
{
if (textBox1.InvokeRequired)
{
BeginInvoke(new Action<string>(DoAppendLog), line);
}
else
{
DoAppendLog(line);
}
}
private void DoAppendLog(string line)
{
if (textBox1.Lines.Length > 99)
{
var builder = new StringBuilder(textBox1.Text);
// strip out a nice chunk from the beginning
builder.Remove(0, textBox1.Text.IndexOf('\r', 500) + 2);
builder.Append(line);
textBox1.Clear();
// using AppendText since that makes sure the TextBox stays
// scrolled at the bottom
textBox1.AppendText(builder.ToString());
}
else
{
textBox1.AppendText(line);
}
}