Giter VIP home page Giter VIP logo

Comments (4)

ufrisk avatar ufrisk commented on July 17, 2024

It's a 500ms wait, not a 1500ms wait, and there are some reasons for it.

The CreateThread creates a thread which performs some cleanup tasks. The cleanup task is started as a separate thread since it sometimes gets stuck / hangs - sometimes due to external libraries.

That is the reason why I create a separate thread with a Sleep afterwards instead of having all the cleanup tasks in the main thread alternatively wait for thread exit with the WaitForSingleObject.

The TerminateProcess is an async call and the process will normally terminate before the Sleep(1000) has executed any meaningful time. In total it's more equivalent to a ~500ms wait - which is kinda ok.

from memprocfs.

tathanhdinh avatar tathanhdinh commented on July 17, 2024

Hi @ufrisk , thank you for the response.

That is the reason why I create a separate thread

I understand that in reading your comment in the code, and

The TerminateProcess is an async call and the process will normally terminate before the Sleep(1000)

is ok (we are supposing that Sleep(1000) has very little change to be executed).

But I still don't understand why you've used Sleep, because such a piece:

CreateThread(...);
Sleep(500); // so it delays the process for 500ms

IMHO, can always be replaced (and probably better) by

HANDLE h = CreateThread(...);
WaitForSingleObject(h, 500); // so it delays the process for at most 500ms

from memprocfs.

ufrisk avatar ufrisk commented on July 17, 2024

Thanks 👍 I'll change it in the next version which I'll hopefully push some time in September (with full registry support).

from memprocfs.

ufrisk avatar ufrisk commented on July 17, 2024

Implemented, shutdown times are now noticeably faster. Thanks.

https://github.com/ufrisk/MemProcFS/blob/master/MemProcFS/memprocfs.c#L74

from memprocfs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.