Performing Asynchronous Remote WMI Calls C#

IT. Delinquent
1 min readAug 5, 2021

This was a problem that I was stuck on for a long time. Originally, I made a program in PowerShell that I and a couple of other people in the company used to query remote computers to retrieve certain information (SN etc).

I wanted to make the move to using WPF with C# simply because of its scale, simplicity and flexibility. The things that I saw being done in WPF with C# was beyond anything I could ever dream of with PowerShell.

After making the initial leap, I realised how much code I would have to re-write/re-imagine into C# code. Go figure…

One thing that I thought would be simple is performing asynchronous operations but this proved to be something I should use with caution. See, I could simply use Task.Run() and perform the actions, but this is like using a sledgehammer to drive in a tac.

After a lot of research, I moved from using this to using an observer class to watch the operation and using the QueryInstancesAsync method instead of QueryInstances()

This is the code that I ended up with:

IT. Delinquent

A humble tech enthusiast and dad writing articles about the tasks I perform whilst working. Hopefully, you find something useful… I never do.