}
此外模拟器在运行结束时,不能保证执行重载的UninitializeComponent函数,所以无法保存内存的数据,代码如下。
/// <summary>
/// Called by the emulator after all components were setup and registered
/// </summary>
public override void InitializeComponent()
{
base.InitializeComponent();
_form = new YFEmulatorForm(this.Emulator);
_form.OnInitializeComponent();
//Launch the UI thread.
Thread uiThread = new Thread(RunForm);
uiThread.SetApartmentState(ApartmentState.STA);
uiThread.Start();
//读Flash数据
EmulatorFlashPersistance.Load(this);
//必须添加这句,否则不会执行UninitializeComponent方法
Application.DoEvents(); //这是我添的
}
/// <summary>
/// Called by the emulator after the program exits
/// </summary>
public override void UninitializeComponent() //这个函数不能保证会运行
{
//保存数据
EmulatorFlashPersistance.Save(this); //所以无法保存最后的结果
Application.DoEvents(); //保存数据
base.UninitializeComponent();
//When the Micro Framework is shutting down, inform the the WinForm application
//to exit as well.
Application.Exit();
}
目前该工作的开展对我来说,实在是一个不小的挑战。由于国内研究.Net Micro Framework不多,不仅没有人进行深层次的讨论,也少见相关资料,所以.Net Micro Framework推广真是任重而道远啊。

