English 中文(简体)
开放式XML文档,新版?
原标题:Opening XML file in a new thread?

Hi trouble

//This is ran when the user presses the Enter Key
Thread LoadThread = new Thread(new ThreadStart(Test));
LoadThread.Start();

private static void Test()
{
    FileStream stream = File.Open("TEST_1.xml", FileMode.Open);
    //----
    //  Code Using File (I know this stuff works)
    //----
    stream.Close();
}

页: 1

DirectoryTEST_1.xml,因为这是另一个过程使用的。

但是,如果它不是自己一面的read子,它就会做罚款?

感谢帮助,如果这样做的话,如何在没有我方案的情况下打开档案 在档案开始之前冻结?

再次感谢。

最佳回答

我使用了你的样本代码,没有遇到任何问题。 然而,在阅读档案时,当我敦促进入钥匙时,我确实有同样的例外。 (一) 要求进入钥匙两倍) 您有两名操作员,负责输入钥匙,这两份文件都开启。 您可在卷宗上打一个断点。 公开声明,看一看在例外情况发生之前受到多少次攻击。

问题回答

你们是否有法典或文件编写程序? 如果是,你需要做一些工作:

private static object _fileLock = new object();

private static void Test()
{
    lock(_fileLock)
    {
        using(FileStream stream = File.Open("TEST_1.xml", FileMode.Open))
        {
            //Stuff you know works
        }
    }
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签