We have a proper working C# Windows Forms Application to take pictures on external Events, send from external hardware connected by Ethernet. Now it should be used by a Broswser via a Webinterface instead of the Forms.WebBrowser control.
So I added a minimal Webserver, running in a Thread:
private void WebServerThread(int port)
{
try
{
//start listing on the given port
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
tcpIpListener = new TcpListener(localAddr, (int)port);
tcpIpListener.Start();
//start the thread which calls the method 'StartListen'
Thread th = new Thread(new ThreadStart(StartListen));
th.Start();
}
catch (Exception e)
{
...
}
}
public void StartListen()
{
while (bServerRunning)
{
...
Socket mySocket = tcpIpListener.AcceptSocket();
...
data = getHtmlPageFromSequencer(dataFromClient);
SendToBrowser(data, ref mySocket);
...
}
}
Opening the "StartWorkAndTakePictures"-Page starts the same process like before (in the old IEBrowserControl), the next Page is displayed, the Camera is initialised, the external device is started, send it's events, the camera take the shots at the correct times. Up to here it's like before...
BUT the event "Camera_SDKProgressCallbackEvent" (EDSDK.ObjectEvent_DirItemRequestTransfer = 0x00000208) from the Canon-SDK is not send (or recogniced), the the pictures are still on the Camera and not downloaded.
To clearify it: The same Program used with the WebBrowser-Control of the Main-Window works fine - the Event is called and the pictures are downloaded as well.
I'm thinking it's a Message Loop Problem, but I'm not so familiar with C# to fnd the error.
Solution:
Adding "Application.DoEvents();" at the Loop which receives the commands from the external hardware and trigger the camera solves my problem.