我是起了一个线程,线程的实现函数如下。可以编译通过,但是运行时出现内存错误。但不调试每次运行到指针转换就会报unhandled exception in JYF.exe: OXC0000005  Access violation。
我觉得应该是指针转换有问题,但是应该怎么写呢?谢谢赐教!UINT ThreadProcMaichong(LPVOID IpParam)
{
THREAD_PARAM* pThreadParam=(THREAD_PARAM*)IpParam; CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();
  CJYFView *pView=(CJYFView*)pMainFrame->GetActiveView();
while (run)
{
pView->m_AdvAo.SetChannelNow(1);//正转控制
pView->m_AdvAo.SetDataAnalog(5);
delay_us(100000); pView->m_AdvAo.SetChannelNow(0);
pView->m_AdvAo.SetDataAnalog(5);
delay_us(sj);
pView->m_AdvAo.SetChannelNow(0);
pView->m_AdvAo.SetDataAnalog(0);
delay_us(sj);
}
return 0;}