rom-properties icon indicating copy to clipboard operation
rom-properties copied to clipboard

Single-threaded asynchronous svrplus

Open DankRank opened this issue 5 years ago • 5 comments

// The installation is done on a separate thread so that we don't lock the message loop
   - © 2017 Egor 

Well, turns out there is a way to do this without having to resort to multithreading. MsgWaitForMultipleObjects treats message queue as yet another object, allowing us to wait for regsvr32 to finish, while handling incoming messages on the same thread.

Why even bother? Well, IMO, multithreading should only be used when it's actually needed (i.e. in computationally expensive and/or unbounded code). Using it here was more of a hack than anything else. However, there is a benefit to this. Now it's very easy to make regsvr32 run for 32 and 64 bit DLLs at the same time. I'm not sure if that would be a sane thing to do, so I haven't looked into it yet, and I'm not including it in this PR.

DankRank avatar Oct 20 '19 12:10 DankRank

I'll need to take a closer look at this before merging, since I haven't used async functions on Windows.

GerbilSoft avatar Oct 20 '19 16:10 GerbilSoft

There seems to be some visual artifacting when updating the onscreen messages when registering/unregistering DLLs. I'll take a look at fixing this first.

GerbilSoft avatar Jan 18 '20 14:01 GerbilSoft

I'm not sure what's causing the weird window updating. ~~Also, it looks like both DLLs are registered in parallel, which is probably not a good idea, since they both touch the same parts of the registry (even on 64-bit).~~

Leaving this in feature/svrplus-async for now.

EDIT: The DLLs aren't being registered in parallel; the WM_APP_TASK and WM_APP_SIGNAL messages are being used to handle this. However, using the message loop to handle processes is likely what's causing the visual artifacting.

GerbilSoft avatar Jan 18 '20 14:01 GerbilSoft

Check if visual artifacting is present in b557ed4da066edbfb6db2d116a4e6eb02f058a02 and the commit before it (or just bisect. each individual commit should compile, run and work). That commit is supposed to reimplement the DialogBoxW function so that GetMessage can be later replaced, and it might be missing something.

DankRank avatar Jan 18 '20 15:01 DankRank

Looks like I forgot to notify you when I fixed this. I merged the changes from master and tested it, it seems to work fine.

DankRank avatar Aug 13 '22 19:08 DankRank