为什么这个 WinMobile (Compact Framework) 应用程序在拍照后挂起?

发布于 2024-12-10 13:53:50 字数 887 浏览 4 评论 0原文

我在尝试调试/修复应用程序时遇到了非常困难的时间。

简要地: - 我创建了一个“向导”类型的应用程序,它从用户拍照开始(使用照片的通用对话框)

  • 如果用户在尝试使用文本输入窗口(SIP)(小键盘输入窗口)后拍摄照片后,事件循环似乎挂起 - 事件未处理或延迟了一段时间。

  • 如果用户不拍照,SIP 键盘就可以正常工作。

  • 这只发生在我的某些设备上。具体来说,这不是 MC65 上的问题,而是 ES400 上的问题。

看来应用程序的事件循环与我显示表单和拍照的方式搞砸了。

如果使用单个表单创建一个简单的测试应用程序,其中包含一个按钮(事件处理程序拍摄照片)和一个接受输入的文本框。效果很好。但它只是一个单一表单的应用程序,不执行任何其他操作。

当我将拍照与显示表单(制作“向导”)结合起来时,事情就会变得很糟糕。

我想知道我应该运行什么样的事件循环?

本质上,用户拍照然后浏览一些表单(当他们单击“下一步”按钮时,我隐藏一个表单并显示另一个表单。)

拍照后从主表单调用 Form.Show,然后我有类似的内容:

while(UserNotFinished)
{
   Application.DoEvents()
}

其中 UserNotFinished 是按下“提交”按钮后从我的向导/表单设置的标志。

我很乐意提供更多代码,但不确定什么有用。

我是 C# 和 CF 开发的新手(多年的 C++/Win32 开发经验),

真正令人困惑的部分是,它可以在一台设备上运行,但不能在另一台设备上运行。事实上,设备完全挂起。它会结束 activesync 连接,有时我必须通过取出电池来硬重置。

I am having a very difficult time trying to debug/fix an application.

Briefly:
- I created a "wizard" type app that starts with the user taking a photograph (using the common dialog for photos)

  • If the user tries to use the text input window (SIP) (the little keyboard input window) after a photo is taken the event loop seems to hang - the event is not processed or is delayed for a while.

  • If the user does not take a picture the SIP keyboard works great.

  • This only happens on some of my devices. Specifically it is not a problem on an MC65 but is a problem on an ES400.

It appears that the app's event loop gets screwed up with the way I am displaying forms and taking photos.

If created a simple test app with single form containing a button (Event handler takes a photo) and a text box that accepts input. That works fine. But it is only a single form app that does nothing else.

When I combine the photo taking with my form displaying (making a "wizard" ) things go badly.

I wonder what kind of event loop should I be running?

Essentially the user takes a photo then goes through some forms (I hide one form and show another when they click the "next" button.)

The Form.Show is called from the main form after a picture is taken and then I have something like:

while(UserNotFinished)
{
   Application.DoEvents()
}

Where UserNotFinished is a flag set from my wizard/forms after the "submit" button is pressed.

I will be happy to provide more code but not sure what would be useful.

I am new to C# and CF development (lots of years of C++/Win32)

The real confusing part is that this works on one device but not on another. In fact, the device hangs completely. It ends the activesync connection and sometimes I have to hard reset by removing the battery.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

平生欢 2024-12-17 13:53:50

我认为你的问题源于 while(true) { DoEvents();以及您如何尝试在不同形式之间切换。我唯一一次使用 DoEvents() 方法是当我已经处于 Windows 事件范围内并且需要确保消息队列中的某些内容得到处理以便屏幕更新正确时。我建议创建一个控制器类来管理向导的屏幕流程。您可以通过使用 ShowDialog() 来控制屏幕流程并直接在单个调用的范围内执行流程控制,或者您必须使用 Show() 和异步机制,例如订阅和处理特定的表单和控件控制器类中的事件。还看到有关引入另一个线程的评论,请注意 Form 属于创建它们的线程,并且您必须在创建线程的上下文中 Invoke(...) 所有 Form 成员。

I think your problem stems from the while(true) { DoEvents(); } and perhaps how you are trying to go between forms. The only time I've used the DoEvents() method is when I'm already in the scope of a windows event and I need to be sure something in the message queue is processed so screen updates are correct. I'd suggest making a controller class to manage the screen flow for your wizard. You can control the screen flow by either using ShowDialog() and execute the flow control directly in the scope of a single call, or you'll have to use Show() and an asynchronous mechanism such as subscribing to and handling specific form and control events in the controller class. Also saw the comment about introducing another thread, beware that Forms belong to the thread they were created in and you must Invoke(...) all Form members in the context of the creating thread.

所有深爱都是秘密 2024-12-17 13:53:50

唔。很奇怪,

我启动了一个新线程,基本上也调用了 Application.DoEvents() ,它似乎解决了问题...

我不知道为什么

while(true)
{
执行事件()
在主线程

中不起作用。

Hmm. Very strange

I started a new thread and basically call Application.DoEvents() in in as well and it seems to fix the problem...

I don't know why the

while(true)
{
DoEvents()
}

in the main thread doesn't work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文