|
开了3个线程不停的采集。一个小时就出现这个错误。
未处理 System.AccessViolationException
Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Source=System.Windows.Forms
StackTrace:
在 System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
在 System.Windows.Forms.Control.DefWndProc(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.TextBoxBase.WndProc(Message& m)
在 System.Windows.Forms.RichTextBox.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.RunDialog(Form form)
在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
在 System.Windows.Forms.Form.ShowDialog()
在 Dll_Test.Form1.OpenInfo() 位置 E:\C#代码\5173下单器\Dll_Test\Form1.cs:行号 293
在 Dll_Test.Form1.Button登录_Click(Object sender, EventArgs e) 位置 E:\C#代码\5173下单器\Dll_Test\Form1.cs:行号 251
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 Dll_Test.Program.Main() 位置 E:\C#代码\5173下单器\Dll_Test\Program.cs:行号 17
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
这是线程代码。
private void ThrCaiji()
{
string html = null, pp = null, dq_xy = null, dq_ddxx = null, dq_jg = null, dq_bt = null, dq_qf = null, dq_sj = null;
bool dq_hg = false;
string[] pp_nr = null;
_a cj = new _a();
SoundPlayer s = new SoundPlayer(Application.StartupPath + "\\报警.wav");
while (true)
{
if (zzxc) { break; }
Thread.Sleep(800);
for (int j = 0; j < 1; j++)//查找最后几页的 1
{
try
{
html = cj.gethttp(qwy((int.Parse(zys) - j).ToString()), "Get", "", "", false, "gb2312");
//html = cj.dqwynr(qwy((int.Parse(zys) - j).ToString()));
Monitor.Enter(this);//进入线程锁
zys = cj.qzys(html);
Monitor.Exit(this); //退出
pp = cj.zzppwb(html, "<ul class=\"pdlist_info\">[\\s|\\S]*?<ul class=\"pdlist_num\">"); //一次
pp_nr = pp.Split(new string[] { "|||" }, StringSplitOptions.None);
for (int i = 0; i < pp_nr.Length; i++) //遍历过滤.
{
dq_xy = cj.qxyd(pp_nr[i]); //网页信誉
dq_hg = cj.xysfhg(szxy, dq_xy); //是否合格
if (dq_hg)
{
Monitor.Enter(this);//进入线程锁
dq_ddxx = cj.qddxx(pp_nr[i]); //订单信息
dq_jg = cj.qjg(pp_nr[i]); //取价格。
// TextBox.AppendText(dq_jg);
dq_sj = cj.dwb(Application.StartupPath + "\\订单数据库.txt");
if (cj.zfccz(dq_sj, dq_ddxx + "|" + dq_jg) < 0) //有新单。
{
dq_bt = cj.qbt(pp_nr[i]); //标题
dq_qf = cj.qqf(pp_nr[i]); //区
//插入列表。
this.listView1.Items.Insert(0, "").SubItems.AddRange(new string[] { "", "", "", "", "", "" });//插入一项目 6项
this.listView1.Items[0].SubItems[0].Text = (listView1.Items.Count).ToString();
this.listView1.Items[0].SubItems[1].Text = dq_bt;
this.listView1.Items[0].SubItems[2].Text = dq_jg;
this.listView1.Items[0].SubItems[3].Text = dq_xy;
this.listView1.Items[0].SubItems[4].Text = dq_qf;
this.listView1.Items[0].SubItems[5].Text = dq_ddxx;
this.listView1.Items[0].SubItems[6].Text = "下单";
//this.listView1.Items[0].SubItems[0].BackColor = Color.SkyBlue;
cj.xwb(Application.StartupPath + "\\订单数据库.txt", dq_ddxx + "|" + dq_jg);
AppendText(Color.Black, DateTime.Now.ToString() + " 新订单:" + dq_ddxx + "|" + dq_jg);
if (报警.Checked)
{
s.Play();
}
}
Monitor.Exit(this); //退出
}
}
}
catch { }
}
}
}
|
-
错误提示
|