Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. delegate Question

delegate Question

Scheduled Pinned Locked Moved C#
questioncomdesigntoolshelp
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Programm3r
    wrote on last edited by
    #1

    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: ^_^

    G 1 Reply Last reply
    0
    • P Programm3r

      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: ^_^

      G Offline
      G Offline
      GuyThiebaut
      wrote on last edited by
      #2

      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.
      P 1 Reply Last reply
      0
      • G GuyThiebaut

        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.
        P Offline
        P Offline
        Programm3r
        wrote on last edited by
        #3

        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: ^_^

        G T 2 Replies Last reply
        0
        • P Programm3r

          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: ^_^

          G Offline
          G Offline
          GuyThiebaut
          wrote on last edited by
          #4

          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.
          P 1 Reply Last reply
          0
          • P Programm3r

            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: ^_^

            T Offline
            T Offline
            Tim Paaschen
            wrote on last edited by
            #5

            Try BeginInvoke() for asynchronous execution of the delegate.

            P 1 Reply Last reply
            0
            • G GuyThiebaut

              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.
              P Offline
              P Offline
              Programm3r
              wrote on last edited by
              #6

              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: ^_^

              G 1 Reply Last reply
              0
              • T Tim Paaschen

                Try BeginInvoke() for asynchronous execution of the delegate.

                P Offline
                P Offline
                Programm3r
                wrote on last edited by
                #7

                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: ^_^

                T 1 Reply Last reply
                0
                • P Programm3r

                  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: ^_^

                  T Offline
                  T Offline
                  Tim Paaschen
                  wrote on last edited by
                  #8

                  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.

                  P 1 Reply Last reply
                  0
                  • T Tim Paaschen

                    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.

                    P Offline
                    P Offline
                    Programm3r
                    wrote on last edited by
                    #9

                    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: ^_^

                    B 1 Reply Last reply
                    0
                    • P Programm3r

                      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: ^_^

                      G Offline
                      G Offline
                      GuyThiebaut
                      wrote on last edited by
                      #10

                      Just been in a meeting :zzz: so did not have time to post this clickety

                      You always pass failure on the way to success.
                      1 Reply Last reply
                      0
                      • P Programm3r

                        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: ^_^

                        B Offline
                        B Offline
                        Bekjong
                        wrote on last edited by
                        #11

                        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 and RunWorkerCompleted to update your UI in a thread safe way.

                        Standards are great! Everybody should have one!

                        P 1 Reply Last reply
                        0
                        • B Bekjong

                          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 and RunWorkerCompleted to update your UI in a thread safe way.

                          Standards are great! Everybody should have one!

                          P Offline
                          P Offline
                          Programm3r
                          wrote on last edited by
                          #12

                          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: ^_^

                          G 1 Reply Last reply
                          0
                          • P Programm3r

                            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: ^_^

                            G Offline
                            G Offline
                            Gareth H
                            wrote on last edited by
                            #13

                            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.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups