EldoS | Feel safer!

Software components for data protection, secure storage and transfer

MountMedia hangs

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#6239
Posted: 05/14/2008 04:47:41
by Robin Astle (Basic support level)
Joined: 04/15/2008
Posts: 30

When porting my code to CbFs I encountered the following problem:

The code hangs on MountMedia (regardless if I do it before or after adding mountpoints.)
I tried with timeout: 0, 5000 and 30000
#6242
Posted: 05/14/2008 05:13:11
by Volodymyr Zinin (EldoS Corp.)

Hello,

Please specify what build number of Callback File System and what API (.NET 1.1, .NET 2.0, VCL, C++) are you using?
And could you give us the code sources and information how to reproduce the problem?

Thanks.
#6245
Posted: 05/14/2008 05:50:18
by Robin Astle (Basic support level)
Joined: 04/15/2008
Posts: 30

CBFS 2 rc1 using C#

I attached my visual studio project.


[ Download ]
#6249
Posted: 05/14/2008 08:44:14
by Volodymyr Zinin (EldoS Corp.)

The problem is in the mOutput.Write calls. You can't use GUI-specific operations in the callbacks. They're cause of a deadlock.
Also I found that you use MessageBox.Show. It's not possible too.
#6250
Posted: 05/14/2008 08:51:39
by Volodymyr Zinin (EldoS Corp.)

If you want to call GUI functions then do it asynchronously. For example let mOutput.Write places logs into some buffer and notifies another thread to take the logs from this buffer and call anything.
#6251
Posted: 05/14/2008 09:24:52
by Robin Astle (Basic support level)
Joined: 04/15/2008
Posts: 30

Code
class TextBoxOutput : AlfrescoOutput
    {
        /**
         * The textbox to which to write output to, this box should be multiline.
         */
        private TextBox mOutput;

        private bool mClosing = false;

        /**
         * Disabled constructor
         */
        private TextBoxOutput()
        {
            throw new Exception("Call of a private constructor: TextBoxOutput");
        }

        public TextBoxOutput(TextBox output)
        {
            if (!output.Multiline)
            {
                throw new Exception("The provided parameter should be a multiline edit box");
            }
            mOutput = output;
        }

        public bool Closing
        {
            get
            {
                return mClosing;
            }
            set
            {
                mClosing = value;
            }
        }

        #region AlfrescoOutput Members

        public void Write(string msg)
        {
            if (!mClosing)
            {
                string[] par = { System.DateTime.Now + ": " + msg + "\r\n" };
                Append myAppend = new Append(AppendOutput);
                mOutput.Invoke(myAppend, par);
            }
        }

        #endregion

        private delegate void Append(string msg);

        private void AppendOutput(string msg)
        {
            if (mOutput != null)
            {
                mOutput.AppendText(msg);
            }
        }
    }


This the output I implemented, as you can see I let my GUI thread call my delegate so the updating of the GUI is done in the GUI thread. This approach worked fine in the previous version of cbfs.
#6252
Posted: 05/14/2008 09:38:25
by Robin Astle (Basic support level)
Joined: 04/15/2008
Posts: 30

I did remove the outputs and indeed the problem was solved, any idea why this did work before?
#6253
Posted: 05/14/2008 11:01:23
by Volodymyr Zinin (EldoS Corp.)

We've corrected the code and will create an update now. But anyway don't use the Invoke method because it's synchronous (it waits until the destination thread completes the call). Use BeginInvoke instead.
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

Topic viewed 4116 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!