我有一個pary API。它只是將媒體流式傳輸到給定的IP端口(從捕獲設備讀取媒體)。Library API調用中的奇怪行爲(NET和C++)
當我在Windows窗體應用程序中使用該API時,它可以工作。但是,當我在控制檯或Windows服務中調用此API時,它不會給出任何錯誤,但不起作用[不流]:它似乎不會從設備接收流數據。
唯一的區別是One Applications是Windows窗體應用程序,另一個不是.. 除此之外確實沒有什麼區別。
什麼樣的依賴可能會導致這樣的事情?任何想法 ?
PS:API是用C++編寫的。我用網,API(C++/CLI)
例如:
// Works in Windows Form Application
System::Void startButton_Click(System::Object^ sender, System::EventArgs^ e)
{
MyAPI->Start();
}
System::Void stopButton_Click(System::Object^ sender, System::EventArgs^ e)
{
MyAPI->Stop();
}
但是....
// Not Work In Console or Windows Service
MyAPI->Start();
Console::WriteLine("Streaming started.Press enter to exit");
Console::Read();
MyAPI->Stop();
Console::WriteLine("Streaming stopped");
有沒有簡單的方法來模擬 - 將消息隊列發送到控制檯或Windows服務應用程序? – Novalis
如果第三方api提供一個服務入口點,您可以在收到消息時進行調用,是的。如果第三方創建一個隱藏窗口來接收消息,那麼:是的。如果第三方API提供了一個運行帶回調設施的消息循環的函數:是的。查看MSDN上關於GetMessage()win api函數的謬誤。 –
謝謝。將檢查GetMessage() – Novalis