5 个解决方案
#1
W_InitSoft是你自己的类还是第三方的类?
1、如果是前者,应该是W_InitSoft没有正确调用第三方类
2、后者:估计是需要传入什么参数
1、如果是前者,应该是W_InitSoft没有正确调用第三方类
2、后者:估计是需要传入什么参数
#2
自己的类
namespace KFGL
{
public partial class W_InitSoft : CCWin.CCSkinMain
{
public delegate void OnInitSoftFinished(int isFinish);
public event OnInitSoftFinished onInitSoftFinished;
Thread t_init;
public W_InitSoft()
{
InitializeComponent();
InitUtil.onInitialStatusResult += InitUtil_onInitialStatusResult;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
private void InitThreadMethod()
{
InitUtil.InitSoftware();
onInitSoftFinished(1);
}
void InitUtil_onInitialStatusResult(int step,string msg)
{
try
{
this.Invoke(new Action(() =>
{
switch (step)
{
case 0:
lbl_step.Text = "初始化变量";
break;
case 1:
lbl_step.Text = "初始化目录";
break;
case 2:
lbl_step.Text = "获取数据";
break;
case 3:
lbl_step.Text = "最后一点操作……";
break;
case 4:
if (Model.Sysinfo.isDebug == true)
{
lbl_step.Text = "新建测试帐号";
}
break;
case 5:
lbl_step.Text = "正在优化存储";
break;
case 6:
lbl_step.Text = "正在更新组件:" + msg;
break;
case 7:
DgUtil.ShowDG(msg);
break;
case 999:
Application.Exit();
break;
}
}));
}
catch
{
}
}
private void W_InitSoft_Load(object sender, EventArgs e)
{
t_init = new Thread(InitThreadMethod);
t_init.IsBackground = true;
t_init.Start();
}
}
}
namespace KFGL
{
public partial class W_InitSoft : CCWin.CCSkinMain
{
public delegate void OnInitSoftFinished(int isFinish);
public event OnInitSoftFinished onInitSoftFinished;
Thread t_init;
public W_InitSoft()
{
InitializeComponent();
InitUtil.onInitialStatusResult += InitUtil_onInitialStatusResult;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
private void InitThreadMethod()
{
InitUtil.InitSoftware();
onInitSoftFinished(1);
}
void InitUtil_onInitialStatusResult(int step,string msg)
{
try
{
this.Invoke(new Action(() =>
{
switch (step)
{
case 0:
lbl_step.Text = "初始化变量";
break;
case 1:
lbl_step.Text = "初始化目录";
break;
case 2:
lbl_step.Text = "获取数据";
break;
case 3:
lbl_step.Text = "最后一点操作……";
break;
case 4:
if (Model.Sysinfo.isDebug == true)
{
lbl_step.Text = "新建测试帐号";
}
break;
case 5:
lbl_step.Text = "正在优化存储";
break;
case 6:
lbl_step.Text = "正在更新组件:" + msg;
break;
case 7:
DgUtil.ShowDG(msg);
break;
case 999:
Application.Exit();
break;
}
}));
}
catch
{
}
}
private void W_InitSoft_Load(object sender, EventArgs e)
{
t_init = new Thread(InitThreadMethod);
t_init.IsBackground = true;
t_init.Start();
}
}
}
#3
这样一个一个问是不是问不清楚啊?那我问下,就是这个异常一般来说会是哪里出现错误嘛
#4
应该InitUtil_onInitialStatusResult方法里错误,在 switch (step)处加断点,一步步调,应该会出来答案
#5
好,我试试
#1
W_InitSoft是你自己的类还是第三方的类?
1、如果是前者,应该是W_InitSoft没有正确调用第三方类
2、后者:估计是需要传入什么参数
1、如果是前者,应该是W_InitSoft没有正确调用第三方类
2、后者:估计是需要传入什么参数
#2
自己的类
namespace KFGL
{
public partial class W_InitSoft : CCWin.CCSkinMain
{
public delegate void OnInitSoftFinished(int isFinish);
public event OnInitSoftFinished onInitSoftFinished;
Thread t_init;
public W_InitSoft()
{
InitializeComponent();
InitUtil.onInitialStatusResult += InitUtil_onInitialStatusResult;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
private void InitThreadMethod()
{
InitUtil.InitSoftware();
onInitSoftFinished(1);
}
void InitUtil_onInitialStatusResult(int step,string msg)
{
try
{
this.Invoke(new Action(() =>
{
switch (step)
{
case 0:
lbl_step.Text = "初始化变量";
break;
case 1:
lbl_step.Text = "初始化目录";
break;
case 2:
lbl_step.Text = "获取数据";
break;
case 3:
lbl_step.Text = "最后一点操作……";
break;
case 4:
if (Model.Sysinfo.isDebug == true)
{
lbl_step.Text = "新建测试帐号";
}
break;
case 5:
lbl_step.Text = "正在优化存储";
break;
case 6:
lbl_step.Text = "正在更新组件:" + msg;
break;
case 7:
DgUtil.ShowDG(msg);
break;
case 999:
Application.Exit();
break;
}
}));
}
catch
{
}
}
private void W_InitSoft_Load(object sender, EventArgs e)
{
t_init = new Thread(InitThreadMethod);
t_init.IsBackground = true;
t_init.Start();
}
}
}
namespace KFGL
{
public partial class W_InitSoft : CCWin.CCSkinMain
{
public delegate void OnInitSoftFinished(int isFinish);
public event OnInitSoftFinished onInitSoftFinished;
Thread t_init;
public W_InitSoft()
{
InitializeComponent();
InitUtil.onInitialStatusResult += InitUtil_onInitialStatusResult;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
private void InitThreadMethod()
{
InitUtil.InitSoftware();
onInitSoftFinished(1);
}
void InitUtil_onInitialStatusResult(int step,string msg)
{
try
{
this.Invoke(new Action(() =>
{
switch (step)
{
case 0:
lbl_step.Text = "初始化变量";
break;
case 1:
lbl_step.Text = "初始化目录";
break;
case 2:
lbl_step.Text = "获取数据";
break;
case 3:
lbl_step.Text = "最后一点操作……";
break;
case 4:
if (Model.Sysinfo.isDebug == true)
{
lbl_step.Text = "新建测试帐号";
}
break;
case 5:
lbl_step.Text = "正在优化存储";
break;
case 6:
lbl_step.Text = "正在更新组件:" + msg;
break;
case 7:
DgUtil.ShowDG(msg);
break;
case 999:
Application.Exit();
break;
}
}));
}
catch
{
}
}
private void W_InitSoft_Load(object sender, EventArgs e)
{
t_init = new Thread(InitThreadMethod);
t_init.IsBackground = true;
t_init.Start();
}
}
}
#3
这样一个一个问是不是问不清楚啊?那我问下,就是这个异常一般来说会是哪里出现错误嘛
#4
应该InitUtil_onInitialStatusResult方法里错误,在 switch (step)处加断点,一步步调,应该会出来答案
#5
好,我试试