Program stalls
jfamvg opened this issue · comments
Hello r1pper,
I used you library to connect to my gopro hero3 white edition with a winform application, but when i try to connect: _camera = Camera.Create("10.5.5.9"); my complete program stalls at: SendRequestAsync() -> using (var response = await request.GetResponseAsync() as HttpWebResponse).
When i run the command (http://10.5.5.9/bacpac/sd) with my browser and a console application i get a result.
I hope you have a quick fix.
Greetings, Jens
@jfamvg Sorry for the late answer
you can't call it directly from UI thread call Camera.Create from another thread or use Camera.CreateAsync to spawn a task for it.
here is an example to retrieve camera name using tasks:
var task = Task.Run<Camera>(() => Camera.Create<Hero3.Hero3Camera>("10.5.5.9"));
var cam=task.Result;
MessageBox.Show(cam.InformationCache().Name);
or in traditional manner in another thread
var thread = new Thread(CreateCamera);
thread.Start();
private void CreateCamera()
{
var camera = Camera.Create<Hero3.Hero3Camera>("10.5.5.9");
//other camera stuff here
}
in windows forms I think you're better off to call all camera methods from another thread and update UI based on the results.
sorry for the inconvenience, I wrote the library with WinRT and WP in mind and those platforms only support Async model.
Best regards
Hessam
@jfamvg OK, I added a Configuration to switch Http Request mode,
write this line before using the library
Configuration.CommandRequestMode = Configuration.HttpRequestMode.Sync;
after the change you can call the methods from UI thread
hope this help
Best regards
Hessam