C#调试错误中的简单JPEG编码器 [英] A Simple JPEG Encoder in C# debugging error

查看:92
本文介绍了C#调试错误中的简单JPEG编码器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.我下载了这个项目;它可以编译并运行良好.但是,当我尝试在Debug中运行它时,出现错误.具体来说,我可以运行到打开文件的位置,但是一旦打开文件,我就会收到此错误:

跨线程操作无效:控件"SettingsGroupBox"是从创建该线程的线程之外的线程访问的.



HI. I downloaded this project; it compiles and runs fine. BUT when I try to run it in Debug, I get an error. Specifically, I can run to the point of opening a file but as soon as the file is opened I get this error:

Cross-thread operation not valid: Control ''SettingsGroupBox'' accessed from a thread other than the thread it was created on.

in

private void ButtonState(bool state)
{
    SettingsGroupBox.Enabled = state;
    DisplayGroupBox.Enabled = state;
    writeCurrentToJpgToolStripMenuItem.Enabled = state;
    writeJpgToolStripMenuItem.Enabled = state;
    openToolStripMenuItem.Enabled = state;
}



特别是在任何Enabled = state上;行(我试图一一注释掉.

当我尝试学习如何从任意数据动态创建jpg时,我想单步执行该应用程序.有任何想法吗?我正在使用MS Visual C#2010 Express.

谢谢.

RON



specifically on any of the Enabled=state; lines (I tried commenting them out one by one.

As I am trying to learn how to create jpgs dynamically from arbitrary data, I would like to single step through the app. Any ideas? I am using MS Visual C# 2010 Express.

Thanks.

RON

推荐答案

这个问题很容易理解,但修复起来却复杂得多.

您下载的代码编写得很差,并且可能适用于旧版本的.NET Framework,例如1.x.

除了创建表单/控件的线程之外,您无法通过其他线程触摸任何表单或其控件.该修复可能涉及重组应用程序代码并添加代码以将这些控制操作编组到正确的线程.

阅读 [
THe problem is fairly easy to understand, but far more complicated to fix.

The code you downloaded was poorly written and possibly for an older version of the .NET Framework, like 1.x.

You cannot touch any forms or their controls from a seperate thread other than the one that created the forms/controls. Fixing that may involve restructuring the application code and adding code to marshal these control manipulations to the correct thread.

Read this[^] for the hows and whys.


这篇关于C#调试错误中的简单JPEG编码器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆