Multiple event Args in VB 2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Armin Zingler

    #16
    Re: Multiple event Args in VB 2005

    "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb
    Running exactly what you say it always hits my error log and give the
    following:
    Did you get the same error before inserting my debug code?


    Armin

    Comment

    • cmdolcet69

      #17
      Re: Multiple event Args in VB 2005

      On Oct 30, 12:41 pm, "Armin Zingler" <az.nos...@free net.dewrote:
      "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb
      >
      Running exactly what you say it always hits my error log and give the
      following:
      >
      Did you get the same error before inserting my debug code?
      >
      Armin
      no never

      Comment

      • cmdolcet69

        #18
        Re: Multiple event Args in VB 2005

        On Oct 30, 12:41 pm, "Armin Zingler" <az.nos...@free net.dewrote:
        "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb
        >
        Running exactly what you say it always hits my error log and give the
        following:
        >
        Did you get the same error before inserting my debug code?
        >
        Armin
        Sorry it was some code I left in while test....After re adding your
        code I had to make a change with the Debug.Print(arg s(0).ToString)
        the args(1) to (0) because it only has 1 position in the
        array....howeve r looking at the output window I can;t see where its
        writing the comport????

        Comment

        • cmdolcet69

          #19
          Re: Multiple event Args in VB 2005

          On Oct 30, 12:41 pm, "Armin Zingler" <az.nos...@free net.dewrote:
          "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb
          >
          Running exactly what you say it always hits my error log and give the
          following:
          >
          Did you get the same error before inserting my debug code?
          >
          Armin
          Actaully it didn;t print out to my output window however I was able to
          see that there is no sequence for the COM1 or COM2 ports being
          called.....Ther e could be 5 COM2 in a row or it could alternate COM1
          and COM2 there is no pattern what I can see..... So in this
          GetDualDSIInput COM1 Sub how can I read COM1 data and COM 2 data at
          the same time????

          Comment

          • Armin Zingler

            #20
            Re: Multiple event Args in VB 2005

            "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb im Newsbeitrag
            news:0b13f1a1-ef4d-432d-99fe-fcccf6997c55@26 g2000hsk.google groups.com...
            On Oct 30, 12:41 pm, "Armin Zingler" <az.nos...@free net.dewrote:
            "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb
            Running exactly what you say it always hits my error log and give the
            following:
            Did you get the same error before inserting my debug code?
            >
            no never
            You had these two lines:

            dataBackgroundW orker.RunWorker Async(New Object() {currentSerial} )
            dataBackgroundW orker2.RunWorke rAsync(New Object() {currentSerial2 })

            I thought it is obvious that I only added two members to the array. You
            don't have to add the two lines again because they are already there.

            So, again, you just have to _change_ this

            dataBackgroundW orker.RunWorker Async(New Object() {currentSerial} )
            dataBackgroundW orker2.RunWorke rAsync(New Object() {currentSerial2 })

            to this:

            dataBackgroundW orker.RunWorker Async( _
            New Object() {currentSerial, "port 1"} _
            )

            dataBackgroundW orker2.RunWorke rAsync( _
            New Object() {currentSerial2 ,"port 2"} _
            )

            Do NOT insert the two lines again, only CHANGE them. Then the error must go
            away. Run it without breakpoints and without interruption, and then answer
            the question, if only "port 1" is shown in the output/debug window.


            Armin

            Comment

            • Armin Zingler

              #21
              Re: Multiple event Args in VB 2005


              Sorry it was some code I left in while test....After re adding your
              code I had to make a change with the Debug.Print(arg s(0).ToString)
              the args(1) to (0) because it only has 1 position in the
              array....howeve r looking at the output window I can;t see where its
              writing the comport????

              =====

              No! It must have two items because I did add them here:

              .... New Object() {currentSerial, "port 1"})

              You see that the array has two items now. They are referred to by args(0)
              and args(1) in sub DoDualDSIWorkCO M1.


              I wrote "debug/output window". Did you also look in the debug window?


              Armin

              Comment

              • Armin Zingler

                #22
                Re: Multiple event Args in VB 2005


                Actaully it didn;t print out to my output window however I was able to
                see that there is no sequence for the COM1 or COM2 ports being
                called.....Ther e could be 5 COM2 in a row or it could alternate COM1
                and COM2 there is no pattern what I can see..... So in this
                GetDualDSIInput COM1 Sub how can I read COM1 data and COM 2 data at
                the same time????

                ====

                I don't find an error. It should work. Before you don't see the debug output
                ("port 1"/"port 2") I can not help. Did you enable Release
                configuration? Switch to Debug configuration. Otherwise Debug.Print is
                ignored.


                Armin

                Comment

                • cmdolcet69

                  #23
                  Re: Multiple event Args in VB 2005

                  On Oct 30, 12:59 pm, "Armin Zingler" <az.nos...@free net.dewrote:
                  "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb im Newsbeitragnews :0b13f1a1-ef4d-432d-99fe-fcccf6997c55@26 g2000hsk.google groups.com...
                  On Oct 30, 12:41 pm, "Armin Zingler" <az.nos...@free net.dewrote:
                  >
                  "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb
                  >
                  Running exactly what you say it always hits my error log and give the
                  following:
                  >
                  Did you get the same error before inserting my debug code?
                  >
                  no never
                  >
                  You had these two lines:
                  >
                      dataBackgroundW orker.RunWorker Async(New Object() {currentSerial} )
                      dataBackgroundW orker2.RunWorke rAsync(New Object() {currentSerial2 })
                  >
                  I thought it is obvious that I only added two members to the array. You
                  don't have to add the two lines again because they are already there.
                  >
                  So, again, you just have to _change_ this
                  >
                      dataBackgroundW orker.RunWorker Async(New Object() {currentSerial} )
                      dataBackgroundW orker2.RunWorke rAsync(New Object() {currentSerial2 })
                  >
                  to this:
                  >
                      dataBackgroundW orker.RunWorker Async( _
                          New Object() {currentSerial, "port 1"} _
                      )
                  >
                      dataBackgroundW orker2.RunWorke rAsync( _
                          New Object() {currentSerial2 ,"port 2"} _
                      )
                  >
                  Do NOT insert the two lines again, only CHANGE them. Then the error must go
                  away. Run it without breakpoints and without interruption, and then answer
                  the question, if only "port 1" is shown in the output/debug window.
                  >
                  Armin
                  This was your question: Do you only get "port 1"in the debug/output
                  window?
                  My answer: No it will alternate Port1 and Port 2 but some times it
                  will have 4 or 5 port 2 and only 1 port 1 or 6 port 1 and 1 port 2.

                  There is no pattern?
                  Therefore we know that port 1 and port 2 are coming over how can i
                  read both port simultaneously? to get there values returned?

                  Comment

                  • Armin Zingler

                    #24
                    Re: Multiple event Args in VB 2005

                    "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb
                    This was your question: Do you only get "port 1"in the debug/output
                    window?
                    My answer: No it will alternate Port1 and Port 2 but some times it
                    will have 4 or 5 port 2 and only 1 port 1 or 6 port 1 and 1 port 2.
                    >
                    There is no pattern?
                    Therefore we know that port 1 and port 2 are coming over how can i
                    read both port simultaneously? to get there values returned?

                    Aaah, I start seeing what you mean with "simultaneously ".

                    Well,,,,, yes, there is no pattern. Even if you have a dual core or multi
                    core CPU, you can _not_ assume that two tasks running on two cores will do
                    exactly the same at the same time forever. This is because of..._many_
                    reasons. I'm not gonny elaborate on this here. The OS might interrupt the
                    threads at different times or whatever. They are not even started at the
                    same time. And so on. And what even would you expect on a single core CPU?
                    So, no, there is no 100% guaranteed execution of the same code in two
                    threads at the same time. The probability even converges to zero.


                    Obviously you are trying to _synchronize_ two threads or two tasks. This
                    must be done on a higher level. You must implement a synchronization
                    mechanism. How this is done depends on what you are trying to achieve.

                    So, the debug output has shown that both ports are being processed. Period.
                    Now we can go a step further: _What_ do you have to synchronize? Which
                    actual problem are you being faced?


                    Armin

                    Comment

                    • cmdolcet69

                      #25
                      Re: Multiple event Args in VB 2005

                      On Oct 30, 2:06 pm, "Armin Zingler" <az.nos...@free net.dewrote:
                      "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb
                      >
                      This was your question: Do you only get "port 1"in the debug/output
                      window?
                      My answer: No it will alternate Port1 and Port 2 but some times it
                      will have 4 or 5 port 2 and only 1 port 1 or 6 port 1 and 1 port 2.
                      >
                      There is no pattern?
                      Therefore we know that port 1 and port 2 are coming over how can i
                      read both port simultaneously? to get there values returned?
                      >
                      Aaah, I start seeing what you mean with "simultaneously ".
                      >
                      Well,,,,, yes, there is no pattern. Even if you have a dual core or multi
                      core CPU, you can _not_ assume that two tasks running on two cores will do
                      exactly the same at the same time forever. This is because of..._many_
                      reasons. I'm not gonny elaborate on this here. The OS might interrupt the
                      threads at different times or whatever. They are not even started at the
                      same time. And so on. And what even would you expect on a single core CPU?
                      So, no, there is no 100% guaranteed execution of the same code in two
                      threads at the same time. The probability even converges to zero.
                      >
                      Obviously you are trying to _synchronize_ two threads or two tasks. This
                      must be done on a higher level. You must implement a synchronization
                      mechanism. How this is done depends on what you are trying to achieve.
                      >
                      So, the debug output has shown that both ports are being processed. Period.
                      Now we can go a step further: _What_ do you have to synchronize? Which
                      actual problem are you being faced?
                      >
                      Armin
                      I need to take readings from two separate IO devices in this case one
                      device sends two readings over and the other device sends only one
                      reading over.....What i need to achieve is that both devices need to
                      populate there own unique textboxes in the runtime screen. I have
                      written the code for the unique textboxes however i just can't read
                      both com ports at the same time.

                      Comment

                      • Patrice

                        #26
                        Re: Multiple event Args in VB 2005

                        This is still not crystal clear.

                        Define the "same time" ? What is the problem with filling the unique textbox
                        for COM1 when you receive data from COM1 and the unique textbox for COM2
                        when you receive data from COM2 ? At any one time you'll just see whatever
                        was sent last by the particular COM port for this textbox

                        Yes you'll have possibly a slight discrepencies but does it really matter ?
                        Moreover it would be surprising to have those two devices sending their data
                        to your PC at the exact same time so anyway you'll do have a slight
                        difference...

                        If you expect to have the exact same number of data transmitted by those two
                        COM ports (?!) you could just count the data input so that you know that you
                        receive the 11th data from COM1, then the 12 th data from COM1 and then the
                        11th data from COM2 and you'll be able to retrieve the matching data you
                        just got from COM1.

                        --
                        Patrice
                        I need to take readings from two separate IO devices in this case one
                        device sends two readings over and the other device sends only one
                        reading over.....What i need to achieve is that both devices need to
                        populate there own unique textboxes in the runtime screen. I have
                        written the code for the unique textboxes however i just can't read
                        both com ports at the same time.

                        Comment

                        • Armin Zingler

                          #27
                          Re: Multiple event Args in VB 2005

                          I need to take readings from two separate IO devices in this case one
                          device sends two readings over and the other device sends only one
                          reading over.....What i need to achieve is that both devices need to
                          populate there own unique textboxes in the runtime screen. I have
                          written the code for the unique textboxes however i just can't read
                          both com ports at the same time.

                          =====

                          No, you can read them at the "same" time. Please tell us the _actual_
                          problem! You fill one textbox from one port and the other textbox from the
                          other port. If this works, where is the problem?


                          Again, I can only guess what you mean:
                          You want to create a relationship between the data from port 1 and the data
                          from port 2. To achieve this, you wanted to receive data "simultaneously ".
                          Is this right? This would be a kind of turn-based game that you wanted to
                          play. To do this, you have to complete one round by waiting for both ports
                          having finished receiving data. Then you can take the two packages from the
                          two ports and build a relationship. Then start the next round.

                          I assume that the data itself does not contain any information that can help
                          you creating a relationship later. What I can say for sure is that the
                          date/time is _not_ the unique key to create the relationship.


                          Armin

                          Comment

                          • Mark S. Milley

                            #28
                            Re: Multiple event Args in VB 2005



                            Maybe It's just me, but looking at your original question, in relation to
                            the background worker, is can you send more than one argument back and forth
                            to the background worker class.

                            If that is the question, the answer is yes, and you won't need multiple
                            background workers to do what you're trying to accomplish.

                            There are several ways to do this; my preferred method is to create an
                            object dedicated to the task, and pass that to and from the background
                            worker.

                            You can likewise create a class or struct to report back more than one
                            element of progress.

                            Another (worse) ideas; throw the values you want to pass into a hashtable or
                            other collection and pass that through as an argument into the
                            BackgroundWorke r

                            Regards,

                            -Mark


                            "cmdolcet69 " <colin_dolcetti @hotmail.comwro te in message
                            news:85f63e34-a0f1-4d51-bde5-f527a47a0d36@d4 5g2000hsc.googl egroups.com...
                            Can anyone tell me if its possible to do multiple event args in vb.net?

                            Comment

                            Working...