Skip to content

Conversation

@AussieScorcher
Copy link
Member

Version 0.1.18 Release.

eozdil174 and others added 2 commits December 29, 2025 11:54
…n 0.1.18

- Implemented subscription to simulator system events via `SimConnectClient.SubscribeToEventAsync`.
- Added typed event handlers for frame, filename, object add/remove, and extended EX1 system events.
- Introduced helper methods for managing event states: `SetSystemEventStateAsync` and `UnsubscribeFromEventAsync`.
- Enhanced performance by optimizing message processing and memory allocation in SimVar setters.
- Updated bundled `SimConnect.dll` to the latest SDK version.
- Added tests for system event subscription and state management.
@greptile-apps
Copy link

greptile-apps bot commented Dec 29, 2025

Greptile Summary

This release adds system event subscription capabilities and delivers significant performance improvements to the SimConnect.NET library.

Key Changes

  • System Event Subscription: New API for subscribing to SimConnect system events (SubscribeToEventAsync, SetSystemEventStateAsync, UnsubscribeFromEventAsync) with typed event handlers for frame rate, filename, object add/remove, and EX1 events
  • Performance Optimizations:
    • Message processing now executes synchronously instead of spawning worker tasks per dispatch, reducing context switches and CPU overhead
    • SimVar setters use ArrayPool<byte> with pinned memory instead of Marshal.AllocHGlobal, eliminating unmanaged allocations
    • Timeout handling uses linked CancellationTokenSource instead of Task.Delay races, reducing allocations on hot paths
  • Test Coverage: Comprehensive tests verify subscribe/on/off/unsubscribe flows and event receipt
  • SDK Update: Bundled SimConnect.dll updated to latest version

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The implementation is well-structured with proper error handling, comprehensive test coverage, and follows established patterns in the codebase. The performance optimizations (synchronous dispatch, ArrayPool usage, linked cancellation) are correct implementations that reduce allocations without introducing bugs. All new APIs have proper XML documentation and exception handling.
  • No files require special attention

Important Files Changed

Filename Overview
src/SimConnect.NET/SimConnectClient.cs Added system event subscription API and optimized message processing to be synchronous, reducing task allocation overhead
src/SimConnect.NET/SimVar/SimVarManager.cs Optimized memory management using ArrayPool instead of Marshal.AllocHGlobal and improved timeout handling with linked cancellation tokens
tests/SimConnect.NET.Tests.Net8/Tests/SystemEventSubscriptionTests.cs New test verifying system event subscription functionality using the 4sec event
tests/SimConnect.NET.Tests.Net8/Tests/SystemEventStateTests.cs Comprehensive test for system event state management (subscribe, on/off toggling, unsubscribe)

@greptile-apps
Copy link

greptile-apps bot commented Dec 29, 2025

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

Comment on lines +393 to +396
var result = SimConnectNative.SimConnect_SubscribeToSystemEvent(
this.simConnectHandle,
systemEventId,
systemEventName);
Comment on lines +427 to +430
var result = SimConnectNative.SimConnect_SetSystemEventState(
this.simConnectHandle,
systemEventId,
(uint)state);
Comment on lines +460 to +462
var result = SimConnectNative.SimConnect_UnsubscribeFromSystemEvent(
this.simConnectHandle,
systemEventId);
Comment on lines +757 to +764
var result = SimConnectNative.SimConnect_SetDataOnSimObject(
this.simConnectHandle,
definitionId,
objectId,
0,
1,
(uint)dataSize,
dataPtr);
Comment on lines +1007 to +1014
var hr = SimConnectNative.SimConnect_SetDataOnSimObject(
this.simConnectHandle,
definitionId,
objectId,
0,
1,
(uint)cache.TotalSize,
dataPtr);
var request = this.StartRequest<T>(definitionId, objectId, SimConnectPeriod.Once, onValue: null);

using (cancellationToken.Register(() => this.CancelRequest(request)))
CancellationTokenSource? timeoutCts = null;

using (cancellationToken.Register(() => this.CancelRequest(request)))
CancellationTokenSource? timeoutCts = null;
CancellationTokenSource? linkedCts = null;
Comment on lines +108 to +112
catch (Exception ex)
{
Console.WriteLine($" ❌ System event state test failed: {ex.Message}");
return false;
}
Comment on lines +121 to +124
catch
{
// Best-effort cleanup; ignore errors
}
@AussieScorcher AussieScorcher merged commit c75a1f1 into main Dec 29, 2025
7 checks passed
@AussieScorcher AussieScorcher deleted the 0.1.18 branch December 29, 2025 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants