Process will halt when calling DeviceInformation::FindAllAsyncAqsFilter. And it's very very strange. I have no idea what's going on.
When I put this code into a new project, everything runs fine, except for WinDbg outputting Windows Runtime Originate Error - code 40080201 (first chance), but it still runs. However, when I put the code into the production environment, it pauses like a deadlock, and WinDbg outputs Windows Runtime Transform Error - code 40080202 (first chance). Even if I put this code at the very beginning of the program, it halts. This is just too bizarre.
Crate manifest
[dependencies]
windows = { version = "0.56", features = [
"Devices_Display",
"Devices_Enumeration",
"Foundation_Collections",
] }
Crate code
use windows::Devices::{Display::DisplayMonitor, Enumeration::DeviceInformation};
pub(crate) fn init_displays() -> Vec<DisplayMonitor> {
println!("1");
let selector = DisplayMonitor::GetDeviceSelector().unwrap();
println!("2: {:?}", selector.to_string_lossy());
let list = DeviceInformation::FindAllAsyncAqsFilter(&selector).unwrap();
println!("3");
let list = list.get().unwrap(); // <- halts here in the production environment
println!("4");
let mut result = Vec::new();
for info in list.into_iter() {
println!("5");
let interface_id = info.Id().unwrap();
let display = DisplayMonitor::FromInterfaceIdAsync(&interface_id).unwrap();
let display = display.get().unwrap();
result.push(display);
}
result
}
fn main() {
println!("Hello, world!");
let displays = init_displays();
println!("{:#?}", displays);
println!("Quiting");
}
Summary
Process will halt when calling
DeviceInformation::FindAllAsyncAqsFilter
. And it's very very strange. I have no idea what's going on.When I put this code into a new project, everything runs fine, except for
WinDbg
outputtingWindows Runtime Originate Error - code 40080201 (first chance)
, but it still runs. However, when I put the code into the production environment, it pauses like a deadlock, andWinDbg
outputsWindows Runtime Transform Error - code 40080202 (first chance)
. Even if I put this code at the very beginning of the program, it halts. This is just too bizarre.Crate manifest
Crate code