Skip to content

Can't initialize with a null SynchronizationContext.Current #37

@danielchalmers

Description

@danielchalmers

If SynchronizationContext.Current is null, VirtualDesktopProvider.Initialize will throw an InvalidOperationException: 'The current SynchronizationContext may not be used as a TaskScheduler.' at

public Task Initialize()
=> this.Initialize(TaskScheduler.FromCurrentSynchronizationContext());

This stops a blank console app from using VirtualDesktop.

Steps to reproduce:

  • Create a new console app
  • Target Windows 10 in app.manifest and add a reference to VirtualDesktop 3 beta
  • In the main method, call VirtualDesktopProvider.Default.Initialize() (or a method that calls it for you like VirtualDesktop.GetDesktops()).

Workaround:
Call SynchronizationContext.SetSynchronizationContext first or use Initialize(TaskScheduler scheduler).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions