4

I'm trying to control a GoPro Hero 3 camera. I found a library on the Internet: https://github.com/r1pper/GoPro.Hero and from what i read it's a nice library. But when I try to create a connection with the camera my complete windows forms application freezes where my console applications (for test) just makes a connection. I think it has something to do with the async tasks, what am I doing wrong?

This line creates the connection with the camera and sends a command:

var camera = Camera.Create<Hero3Camera>("10.5.5.9");
Irvin Dominin
  • 30,819
  • 9
  • 77
  • 111
jfamvg
  • 237
  • 3
  • 10
  • In what class you are doing this? Maybe initiating a camera from GUI thread makes this problem. Try to do this on another thread. – Mehraban Mar 11 '14 at 08:36
  • 1
    Thanks that did the job. I have to put all the commands in a new thread. – jfamvg Mar 11 '14 at 08:48

1 Answers1

5

You can either call your commands from another thread or simply set HttpRequestMode to sync

GoPro.Hero.Configuration.CommandRequestMode = GoPro.Hero.Configuration.HttpRequestMode.Sync

Description:

CommandRequest uses Tasks internally, when we use a blocking method like Create instead of CreateAsync it calls Task.Wait in the method which causes deadlock in UI contexts (using same context as UI thread),by setting Configuration.CommandRequestMode to Sync, it uses an alternate method SendRequestSynchronous which prevents deadlock.

user3473830
  • 7,165
  • 5
  • 36
  • 52