Reputation: 2325
I have a thirt pary API. It simply stream media to given ip-port(read media from a capture device).
When I use that API in a Windows Form Application, it works. But when i call this API in a Console or Windows Service, it does not give any error but does not work[ does not stream ]: It seems that it does not take stream data from device.
The only difference betwween is that One Applications is Windows Form Application, the other is not.. There is really no difference other than this.
What kind of dependency may cause such a thing? Any idea ?
PS: The API is written in C++. I use that API in NET(C++/CLI)
For Example:
// 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();
}
but ....
// 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");
Upvotes: 0
Views: 86
Reputation: 968
In case of a UI-application, there's always a message queue. In a console application, the is not. The 3rd party software might post messages to the message queue that is not there in the console-application. Doing so might cause unpredictable program behaviour. Try calling GetMessage() from the win api before the communication is started.
Upvotes: 0
Reputation: 14751
The third party API probably depends internally on Windows event dispatching, which a console app will not do (by default, I believe you can set up event dispatching within a console app).
Upvotes: 1