delegate Question
-
Hi all, I have two delegates namely:
public delegate void initCanonCamara(); public delegate void connectCanonCamara();
I then invoke the delagates by doing the following:connectCanonCamara canonConnect = new connectCanonCamara(CanonConnect); this.Invoke(canonConnect); initCanonCamara canonSdk = new initCanonCamara(CanonSDK); this.Invoke(canonSdk);
But after all that my UI still hangs on startup .... why:confused: ... what am I doing wrong:confused: ? Please help Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Hi all, I have two delegates namely:
public delegate void initCanonCamara(); public delegate void connectCanonCamara();
I then invoke the delagates by doing the following:connectCanonCamara canonConnect = new connectCanonCamara(CanonConnect); this.Invoke(canonConnect); initCanonCamara canonSdk = new initCanonCamara(CanonSDK); this.Invoke(canonSdk);
But after all that my UI still hangs on startup .... why:confused: ... what am I doing wrong:confused: ? Please help Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Hi, Could you compile it then run it in debug mode and post the error message please. Guy
You always pass failure on the way to success.
-
Hi, Could you compile it then run it in debug mode and post the error message please. Guy
You always pass failure on the way to success.
GuyThiebaut wrote:
Could you compile it then run it in debug mode and post the error message please.
Sorry if I caused a misunderstanding, but there is no error message nor error, it's just that, while the camera is being initialized in the delegates the screen hangs until the initialization has finished ... Any suggestions ? Thanks for the reply Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
GuyThiebaut wrote:
Could you compile it then run it in debug mode and post the error message please.
Sorry if I caused a misunderstanding, but there is no error message nor error, it's just that, while the camera is being initialized in the delegates the screen hangs until the initialization has finished ... Any suggestions ? Thanks for the reply Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Have you tried threading the initialisation process? Use the background worker to initialise the camera and once it has been initialised make it available though your app.
You always pass failure on the way to success.
-
GuyThiebaut wrote:
Could you compile it then run it in debug mode and post the error message please.
Sorry if I caused a misunderstanding, but there is no error message nor error, it's just that, while the camera is being initialized in the delegates the screen hangs until the initialization has finished ... Any suggestions ? Thanks for the reply Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Try
BeginInvoke()
for asynchronous execution of the delegate. -
Have you tried threading the initialisation process? Use the background worker to initialise the camera and once it has been initialised make it available though your app.
You always pass failure on the way to success.
GuyThiebaut wrote:
Use the background worker to initialise the camera and once it has been initialised make it available though your app.
No I haven't ... not even sure how to do something like that :sigh: Thanks for the reply Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Try
BeginInvoke()
for asynchronous execution of the delegate.Hi, Thanks for the reply ... But it doesn't make a difference Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Hi, Thanks for the reply ... But it doesn't make a difference Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
I had a second look at your code snippet. I guess that
this
(on which you call Invoke) ist your control. You may try to call BeginInvoke on the delegate itself. -
I had a second look at your code snippet. I guess that
this
(on which you call Invoke) ist your control. You may try to call BeginInvoke on the delegate itself.I just wat to add that the function that is accosiated with the delegate is updating controls on the form. Will this xcause the problem?
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
GuyThiebaut wrote:
Use the background worker to initialise the camera and once it has been initialised make it available though your app.
No I haven't ... not even sure how to do something like that :sigh: Thanks for the reply Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Just been in a meeting :zzz: so did not have time to post this clickety
You always pass failure on the way to success.
-
I just wat to add that the function that is accosiated with the delegate is updating controls on the form. Will this xcause the problem?
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Yes, since you need to do any updates to the UI from the thread they were created on (this would usually be the main thread in your program). I suggest using a BackgroundWorker[^]. You can assign it to do all non UI related work in
DoWork
and then use ReportProgress andRunWorkerCompleted
to update your UI in a thread safe way.Standards are great! Everybody should have one!
-
Yes, since you need to do any updates to the UI from the thread they were created on (this would usually be the main thread in your program). I suggest using a BackgroundWorker[^]. You can assign it to do all non UI related work in
DoWork
and then use ReportProgress andRunWorkerCompleted
to update your UI in a thread safe way.Standards are great! Everybody should have one!
Thanks for the help :)
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Thanks for the help :)
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Programm3r, Just on a side note, you don't need to declare two delegates. Only one. Since a delegate is determined by the params its passed. Just thought i'd tell you that so it saves you time in the future if you need to use a lot of delegates. I hope you understand, if not, say so and i'll find a URL that explains it better. Regards, Gareth.