Commit graph

35 commits

Author SHA1 Message Date
Jack251970
2adbc334a2 Improve semaphore lock handling and code robustness
Added `lockAcquired` flags in `PluginsManifest.cs` and `Main.cs`
to ensure semaphore locks are only released if successfully
acquired, preventing potential runtime errors. Updated `finally`
blocks to conditionally release locks based on these flags.

Removed redundant cancellation check in `EverythingAPI.cs` to
simplify code, assuming cancellation is handled elsewhere. These
changes enhance reliability and maintainability of the codebase.
2025-11-07 15:30:07 +08:00
Jack251970
88fd1e56d0 Handle OperationCanceledException gracefully
Added a `catch` block for `OperationCanceledException` in
`PluginsManifest.cs` to ignore canceled operations. Updated
`EverythingAPI.cs` to use cancellation tokens with `_semaphore.WaitAsync`
and handle cancellations by exiting the method cleanly with `yield break`.
2025-11-06 20:47:54 +08:00
Jack251970
49f89e33b5 Make locking operations cancelable with tokens
Updated `_semaphore.WaitAsync` in `EverythingAPI.cs` to accept a `CancellationToken` and handle `OperationCanceledException` gracefully, returning `false` instead of propagating the exception.

Refactored locking mechanisms in `Main.cs` to use `CancellationToken` for `_win32sLock` and `_uwpsLock`. Added `try-catch` blocks to handle `OperationCanceledException` and ensure proper lock release. Methods now return `emptyResults` when operations are canceled.
2025-11-06 20:46:29 +08:00
Jack251970
d0a47c84b9 Clarify CancellationToken handling in comments
Updated comments to explain the rationale for not directly passing
CancellationToken to methods and instead checking
IsCancellationRequested within locks. This prevents unexpected
OperationCanceledException. Changes made in EverythingAPI.cs
(IsEverythingRunningAsync) and Main.cs (Win32 and UWP program
preparation). No functional changes to the code.
2025-11-06 15:39:19 +08:00
Jack251970
bfaff5cca5 Improve semaphore usage and logging clarity
Added comments in `EverythingAPI.cs` and `Main.cs` to explain
why `CancellationToken` is not directly passed to semaphore
locks, preventing unexpected `OperationCanceledException`.

Updated debug log messages in `Main.cs` for better clarity,
including changing "Start handling programs" to "Start querying
programs". Removed redundant log messages to improve logging
consistency.
2025-11-06 15:32:08 +08:00
Jack251970
30d7f67d42 Refactor token cancellation check for readability
Simplified the `if` statement that checks for token cancellation
by condensing it into a single line. This improves code readability
and eliminates unnecessary line breaks.
2025-11-06 15:30:32 +08:00
Jack251970
3d8fd1d352 Improve cancellation, locking, and logging mechanisms
Enhanced cancellation handling by adding `token.IsCancellationRequested` checks to improve responsiveness. Refactored locking mechanisms for `_win32sLock` and `_uwpsLock` using `try-finally` blocks to ensure proper acquisition and release, improving thread safety and preventing deadlocks.

Reorganized Win32 and UWP program querying logic for better modularity and readability. Replaced shared collection access with local variables to improve clarity and maintain thread safety. Simplified empty result handling by directly returning `emptyResults` when canceled.

Removed redundant debug log statements to reduce verbosity and updated remaining logs for clarity. Suppressed unused result warnings by replacing direct calls to `EverythingApiDllImport.Everything_GetMajorVersion()` with null-coalescing assignments.
2025-11-06 15:28:13 +08:00
Jack251970
db0c86d50c Remove CancellationToken from semaphore WaitAsync calls
Removed the `CancellationToken` parameter from `WaitAsync` calls
on semaphores in `EverythingAPI.cs` and `Main.cs`. This change
eliminates cancellation support for semaphore waits, likely due
to a design decision prioritizing simplicity or avoiding issues
with cancellation handling.

In `EverythingAPI.cs`, `WaitAsync(token)` was replaced with
`WaitAsync()` in two methods. Similarly, in `Main.cs`, the
`WaitAsync` calls for `_win32sLock` and `_uwpsLock` were updated
to remove the `token` parameter.

Note: This change may impact the ability to gracefully handle
cancellation during semaphore waits.
2025-11-04 14:25:55 +08:00
VictoriousRaptor
30f7ae0d67 Use Localization for Explorer plugin 2025-07-16 21:28:17 +08:00
Vic
00e6e5b30d Remove unused using 2023-04-25 21:02:34 +08:00
TheBestPessimist
1ed1c99931 Revert "add scoring based on index and small optimization"
This reverts commit 02b321c4a3.
2023-03-15 20:53:14 +02:00
Hongtao
02b321c4a3 add scoring based on index and small optimization 2023-03-14 16:42:09 -05:00
TheBestPessimist
48ed1fec15 more todo 2023-03-14 09:21:11 +02:00
TheBestPessimist
fa971c6b81 Ask Everything for RunCount only if sorting by it 2023-03-08 14:29:46 +02:00
TheBestPessimist
9bc6a4e072 Waiting on a semaphore must be outside of try 2023-03-08 14:29:46 +02:00
TheBestPessimist
84b63e5f54 Use Request Flags when retrieving results from Everything, to be able to retrieve RunCount as well 2023-03-08 14:29:46 +02:00
TheBestPessimist
ac3c955539 Async is hard.
Not sure exactly why the previous version was not working, but i _assume_ it's because I was in a deadlock on that semaphore.
2023-03-08 14:29:46 +02:00
TheBestPessimist
94b841d341 Should be working 2023-03-08 14:29:46 +02:00
TheBestPessimist
f96bf4c592 cleanup 2023-03-08 14:29:46 +02:00
TheBestPessimist
18d1bb5668 Cleanup unused properties 2023-01-26 09:19:42 +02:00
TheBestPessimist
1b9a879d48 Use EverythingSearchOption flag to set up FullPathSearch instead of hardcoding it 2023-01-26 08:58:41 +02:00
TheBestPessimist
2b6c92c48c question to the FL developers 2023-01-26 08:50:42 +02:00
TheBestPessimist
1482637cf1 Everything.MatchPath = true 2023-01-26 08:50:42 +02:00
Hongtao Zhang
e9d8579bbd
fix concurrency issue (really potentially) 2022-12-03 13:50:30 -06:00
Hongtao Zhang
4a0ee9b4fc
fix concurrency issue (potentially) 2022-12-03 13:44:43 -06:00
Hongtao Zhang
22bc292aa9
Add try catch to encounter dllnotfound issue and move warning string to resource 2022-11-28 21:38:27 -06:00
Hongtao Zhang
9267938018
Append Result for everything error and windows index error 2022-11-25 13:25:12 -06:00
Hongtao Zhang
2c3df3f4db
Change signature back to string to accommodate async method.
Port open Windows Context Menu feature
2022-09-24 14:23:59 -05:00
Hongtao Zhang
8b1c125bdf
Custom Exception & Some Refactor
- Try use ReadOnlySpan<char> instead of String for applicable API
- Use Customized Exception to return error result
2022-09-21 19:18:20 -05:00
Hongtao Zhang
000c45bfa8
Refactor Explorer Code to fit the new architecture
1. Rename some method in QueryConstructor.cs by removing prefix and suffix
2. Split the logic of checking '>' to outer SearchManager.cs
3. Use IAsyncEnumerable for potential future improvement.
2022-09-10 10:45:41 -05:00
Hongtao Zhang
a3622d472e
Code Refactor with IAsyncEnumerable instead of Task<IEnumerable> 2022-08-16 18:45:36 -04:00
Hongtao Zhang
9b471de3cf
Implement Path Enumeration and ContentSearch 2022-06-25 12:39:02 -05:00
Hongtao Zhang
fa0cd35e18
Support Path Enumeration (Part 1) 2022-06-25 12:39:02 -05:00
Hongtao Zhang
b671f562ef
Add missing File 2022-06-25 12:39:01 -05:00
Hongtao Zhang
6fdff2971c
Merge Explorer & Everything Plugins (Step 1)
1. Shared Interface for Windows Index and Everything Index
2. Settings Merge (Part 1)
3. Include Everything dll
2022-06-25 12:38:50 -05:00