错误提示:正试图在 OS 加载程序锁内执行托管代码。不要尝试在 DllMain 或映像初始化函数内运行托管代码,这样做会导致应用程序挂起。程序如此:在主程序开始时,创建两个线程,取得并数据刷新存入自定义结构体内。程序运行时从结构体内调用取得的数据。程序退出时,结束线程。此错误发生在结束主程序时。.Net提示。请问如何解决??
解决方案 »
- c# mapx添加动态图层的错误
- SaveFileDialog 不能显示 ,而且线程卡死在那儿
- 发布 (web): 未将对象引用设置到对象的实例。
- 如何打开Excel文档,而不弹出更新对话框?
- 求教为什么不能实现计时器的功能
- 求一Sql语句?
- c/s程序升级后点桌面快捷方式老是要重新安装一次才可以进入登陆界面,我快捷菜单用的是一个引导程序,参照autoupdate
- TrackingLayer的问题!!!在线等,谢谢大家!!!
- 怎么获取一个窗体的句柄?
- 急死了,解决就给分~~~~~~~~~~~帮帮忙啊
- 我已经得到了一个listview的句柄,怎么才能取得里面具体数据?(100分)
- 遍历文件夹下的文件的排序问题?
{
Initlialized = false;
//______________________________________________________________________________
//________________________软适配从数据库中初始化过程____________________________
//______________________________________________________________________________
NpgsqlDataAdapter myAda = eCommonFunction.fGetAdapter("Select proxypcid, wtid FROM wtinfo");
DataSet ids_AdaParm = new DataSet();
myAda.Fill(ids_AdaParm, "WTName");
myAda = eCommonFunction.fGetAdapter("Select distinct b.proxypcid, b.proxypcip From wtinfo a, proxypcinfo b Where a.proxypcid = b.proxypcid");
myAda.Fill(ids_AdaParm, "Proxy");
string[,] AdapterParm = new string[ids_AdaParm.Tables[1].Rows.Count, 2];
int j = 0;
foreach (DataRow ddr in ids_AdaParm.Tables[1].Rows)
{
foreach (DataRow dr in ids_AdaParm.Tables[0].Select("proxypcid=" + ddr[0].ToString()))
{
AdapterParm[j, 1] = AdapterParm[j, 1] + dr[1].ToString() + ",";
}
AdapterParm[j++, 0] = ddr[1].ToString();
}
myAda.Dispose();
ids_AdaParm.Dispose(); SoftAdapterClient = new SoftAdapter(AdapterParm);
Initlialized = true;GetData = new Thread(eGetData);
GetData.Priority = ThreadPriority.Highest;
GetData.IsBackground = true;
GetData.Start(); SaveFile = new Thread(eSaveFileEvent);
SaveFile.Priority = ThreadPriority.Lowest;
SaveFile.IsBackground = true;
SaveFile.Start();
}/// <summary>
/// 结束线程
/// </summary>
public void eTerminate()
{
GetData.Abort();
SaveFile.Abort();
}
F_Main :主程序/// <summary>
/// 数据操作类
/// </summary>
public static DataOperate eDataOperate = new DataOperate();private void F_Main_Shown(object sender, EventArgs e)
{ if (!eDataOperate.Initlialized)
eDataOperate.eInitialize();
}
退出
private void F_Main_FormClosed(object sender, FormClosedEventArgs e)
{
eDataOperate.eTerminate();
Application.Exit();
}
SaveFile是把取得的实时数据存入txt文本文件中。做历史记录。