多线程错误:“对象当前在其他地方使用". [英] Multi-threading error: "Object is currently in use elsewhere."

查看:103
本文介绍了多线程错误:“对象当前在其他地方使用".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个将jpeg转换为十六进制的程序,我正在尝试使用一些线程.我可以调用线程,并且它们可以正常启动,但是在转换过程中,我收到一个错误:对象在其他地方当前正在使用".

如果我不使用相同的资源,我认为这不会成为问题. jpeg.我从jpeg开始,计划转换更大的文件.

我现在在工作,目前无法访问我的代码.现在,我只是在寻求建议.我是多线程的新手. ThreadPool.QueueUserWorkItem是否可以解决问题?任何信息将不胜感激!

I currently writing a program to convert a jpeg to hex and I''m attempting to use a few threads. I''m able to call the threads and they start fine, but along the conversion I receive an error: "Object is currently in use elsewhere."

I don''t think it would be an issue if I wasn''t using the same resource; the jpeg. I''m starting with jpeg''s, and plan on converting much larger files.

I''m at work now and don''t have access to my code at the moment. Right now I''m only looking for advice. I''m new to multi-threading. Would ThreadPool.QueueUserWorkItem solve the issue? Any information would be greatly appreciated!

推荐答案

Ummm,为什么要使用线程来做到这一点.购买文件的本质是十六进制值的集合.只需将其转换即可:

Ummm, why are you using a thread to do that. The file, buy it''s very nature is a collection of hex values. Just convert it:

public static string ByteArrayToString(byte[] byteArray) 
{   
    string hex = BitConverter.ToString(byteArray);   
    return hex.Replace("-",""); 
}


这篇关于多线程错误:“对象当前在其他地方使用".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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