Conversation

0x5bfa

Resolved / Related Issues

Steps used to test these changes

  1. Open Files app
  2. Enable the setting to run Files in the background
  3. Start debebugging Files
  4. Close the window
  5. Launch Files from Start Menu

@0x5bfa

Requesting your review @dongle-the-gadget @hez2010

}
});

HANDLE* pEventHandles = stackalloc HANDLE[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you even need to allocate a stack here? I thought your HANDLE variable is in stack already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to your 2nd comment, it looks like you can't take address of a local variable that goes thru an async lambda/function. The current code doesn't have async and initially did so this can be refactored but IIUC if we wanna use async void we may have to do this.

IntPtr eventHandle = CreateEvent(IntPtr.Zero, true, false, null);

Task.Run(() =>
STATask.RunAsSync(() =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why async void isn't desirable here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you mean adding Wait() in that helper method instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean making it an async lambda and then await.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id like to keep this PR's scope just wrapping the unsafe code into a separate method.

@0x5bfa0x5bfa force-pushed the 5bfa/CQ-RunAsSync branch from c682f2a to fc48386 Compare May 14, 2025 16:04
@0x5bfa0x5bfa force-pushed the 5bfa/CQ-RunAsSync branch from fc48386 to eca313e Compare May 14, 2025 16:05
@0x5bfa

Ready

@dongle-the-gadget

I think it's better to do something like

public Task Something(Task task)
{
    async Task Call()
    {
        await task;
        SetEvent();
    }
}

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.