question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integrating dokan-dotnet into existing application without blocking it

See original GitHub issue

I have an application, that while running I would like for it to publish a custom file system for internal data.

Since this application is doing other things as well, as well as responding to shutdown commands that terminates the application in an orderly fashion I’m looking for how to integrate Dokan into this.

I cloned the dokan-dotnet repository and tried to change the RegistryFS example to do its own unmounting. If I simply run it, and hit Ctrl-C, I see “send global release for r:”, no error messages, and the drive disappears.

Now I want to “unblock” the main program, so I tried changing it to this:

    internal class Program
    {
        private static void MountDrive()
        {
            try
            {   
                var rfs = new RFS();
                rfs.Mount("r:\\", DokanOptions.DebugMode | DokanOptions.StderrOutput);
            }
            catch (DokanException ex)
            {
                Console.WriteLine(@"Error: " + ex.Message);
            }
        }

        private static void Main()
        {
            Task.Factory.StartNew(MountDrive);

            Console.WriteLine("Hit enter to unmount");
            Console.ReadLine();

            Dokan.Unmount('r');
        }
    }

Now, when I hit Enter, this is output:

send global release for r:
Ioctl failed for wait with code 995.
Thread will be terminated
Ioctl failed for wait with code 995.
Thread will be terminated
Ioctl failed for wait with code 995.
Thread will be terminated
Ioctl failed for wait with code 995.
Thread will be terminated
Ioctl failed for wait with code 995.
Thread will be terminated
05/31/2021 14:29:50 - [DokanNet] UnmountedProxy:
05/31/2021 14:29:50 - [DokanNet]        Context {<null>, False, False, False, False, #0, False, False}
05/31/2021 14:29:50 - [DokanNet] UnmountedProxy Return : Success
send global release for r:
DokanError: Ioctl 0x92010 failed with code 122 on Device \\.\Dokan_1
Failed to unmount: r:

Now, the drive does disappear from Windows Explorer, but all those error messages tells me this isn’t how I am supposed to do it.

So my question is this. How can I, from a separate thread in my program, correctly unmount a Dokan-DotNet mounted file system?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
lassevkcommented, May 31, 2021

Good, thanks! Man I have many ideas for the use of this library 😃 Thanks!

1reaction
LTRDatacommented, May 31, 2021

I would strongly recommend you to design the application so that you wait for all Dokan threads before exiting. In this particular case, since you start a task, assign the returned Task object from StartNew to a variable and call the Wait method of that object before returning from Main method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recommended approach to integrate applications without ...
1 Answer 1 ... You need some kind of async and reliable message delivery. So App A won't wait for App B while...
Read more >
Non-Blocking FeatureWriter Output For Real-Time integrations?
But the output from the FeatureWriter seems to always be blocking. We ideally want to use that output to acknowledge the message in...
Read more >
About Non-blocking Operation in the Client Library
An introduction to the non-blocking features of the client library. ... This allows an application to start a query or other operation against...
Read more >
Can Spring Integration cause a Reactive Application to ...
1 Answer 1 ... In most cases Spring Integration components are stateless, so they are safe to use in multi-threaded (or non-blocking) environment....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found