Cant use DoEvents in WPF application

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

    Cant use DoEvents in WPF application

    I have a WPF application in VB in VSTS 2008 RTM. I am trying to
    "blink" (momentarily clear) a field of data if the data is reloaded
    from the database to give the user some visual indication of the LOAD
    operation.

    So on the LOAD button I clear the text fields, do
    mainCanvas.Upda teLayout( ), and the reload the text field from the
    database. But the text fields are not cleared long enough to see them
    blink.

    So I add a Thread.Sleep(20 0) before reloading the text fields. Still
    no visual blink.

    So I change the Sleep(200) to Sleep(2000), Still no visual blink.

    So I attempt to add an Application.DoE vents so that the application
    gets a chance to repaint the screen. But when I attempt to add the
    "Imports System.Windows. Forms" for the DoEvents, the IDE says
    "System.Windows .Forms doesn't contain any public member(s) or cannot
    be found."

    Apparently DoEvents can not be used in a WPF application because it is
    not a Windows Forms.

    OK, so how do I get WPF to visually "blink" some text fields in
    response to a button push?
    How do I replace the DoEvents functionality in a WPF application?
  • Tom Shelton

    #2
    Re: Cant use DoEvents in WPF application

    On 2008-03-18, Don <dbaechtel@gmai l.comwrote:
    I have a WPF application in VB in VSTS 2008 RTM. I am trying to
    "blink" (momentarily clear) a field of data if the data is reloaded
    from the database to give the user some visual indication of the LOAD
    operation.
    >
    So on the LOAD button I clear the text fields, do
    mainCanvas.Upda teLayout( ), and the reload the text field from the
    database. But the text fields are not cleared long enough to see them
    blink.
    >
    So I add a Thread.Sleep(20 0) before reloading the text fields. Still
    no visual blink.
    >
    So I change the Sleep(200) to Sleep(2000), Still no visual blink.
    >
    So I attempt to add an Application.DoE vents so that the application
    gets a chance to repaint the screen. But when I attempt to add the
    "Imports System.Windows. Forms" for the DoEvents, the IDE says
    "System.Windows .Forms doesn't contain any public member(s) or cannot
    be found."
    >
    Apparently DoEvents can not be used in a WPF application because it is
    not a Windows Forms.
    >
    OK, so how do I get WPF to visually "blink" some text fields in
    response to a button push?
    How do I replace the DoEvents functionality in a WPF application?
    Are you referencing System.Windows. Forms.dll?

    --
    Tom Shelton

    Comment

    • Don

      #3
      Re: Cant use DoEvents in WPF application

      On Mar 18, 12:16 pm, Tom Shelton
      <tom_shel...@YO UKNOWTHEDRILLco mcast.netwrote:
      On 2008-03-18, Don <dbaech...@gmai l.comwrote:
      >
      >
      >
      >
      >
      I have a WPF application in VB in VSTS 2008 RTM. I am trying to
      "blink" (momentarily clear) a field of data if the data is reloaded
      from the database to give the user some visual indication of the LOAD
      operation.
      >
      So on the LOAD button I clear the text fields, do
      mainCanvas.Upda teLayout( ), and the reload the text field from the
      database. But the text fields are not cleared long enough to see them
      blink.
      >
      So I add a Thread.Sleep(20 0) before reloading the text fields. Still
      no visual blink.
      >
      So I change the Sleep(200) to Sleep(2000), Still no visual blink.
      >
      So I attempt to add an Application.DoE vents so that the application
      gets a chance to repaint the screen. But when I attempt to add the
      "Imports System.Windows. Forms" for the DoEvents, the IDE says
      "System.Windows .Forms doesn't contain any public member(s) or cannot
      be found."
      >
      Apparently DoEvents can not be used in a WPF application because it is
      not a Windows Forms.
      >
      OK, so how do I get WPF to visually "blink" some text fields in
      response to a button push?
      How do I replace the DoEvents functionality in a WPF application?
      >
      Are you referencing System.Windows. Forms.dll?
      >
      --
      Tom Shelton- Hide quoted text -
      >
      - Show quoted text -
      System.Windows. Forms is not listed in the available Namespaces under
      References in Project Properties.
      I do not think that System.Windows. Forms can be referenced in a WPF
      application.

      Comment

      • Patrice

        #4
        Re: Cant use DoEvents in WPF application

        Apparently DoEvents can not be used in a WPF application because it is
        not a Windows Forms.
        >
        OK, so how do I get WPF to visually "blink" some text fields in
        response to a button push?
        How do I replace the DoEvents functionality in a WPF application?
        >
        You could try :
        http://shevaspace.spac es.live.com/blog/cns!FD9A0F1F8DD 06954!411.entry

        Not familiar yet with WPF but you could perhaps do that by using a WPF
        animation ?

        --
        Patrice



        Comment

        • Tom Shelton

          #5
          Re: Cant use DoEvents in WPF application

          On 2008-03-18, Don <dbaechtel@gmai l.comwrote:
          On Mar 18, 12:16 pm, Tom Shelton
          ><tom_shel...@Y OUKNOWTHEDRILLc omcast.netwrote :
          >On 2008-03-18, Don <dbaech...@gmai l.comwrote:
          >>
          >>
          >>
          >>
          >>
          I have a WPF application in VB in VSTS 2008 RTM. I am trying to
          "blink" (momentarily clear) a field of data if the data is reloaded
          from the database to give the user some visual indication of the LOAD
          operation.
          >>
          So on the LOAD button I clear the text fields, do
          mainCanvas.Upda teLayout( ), and the reload the text field from the
          database. But the text fields are not cleared long enough to see them
          blink.
          >>
          So I add a Thread.Sleep(20 0) before reloading the text fields. Still
          no visual blink.
          >>
          So I change the Sleep(200) to Sleep(2000), Still no visual blink.
          >>
          So I attempt to add an Application.DoE vents so that the application
          gets a chance to repaint the screen. But when I attempt to add the
          "Imports System.Windows. Forms" for the DoEvents, the IDE says
          "System.Windows .Forms doesn't contain any public member(s) or cannot
          be found."
          >>
          Apparently DoEvents can not be used in a WPF application because it is
          not a Windows Forms.
          >>
          OK, so how do I get WPF to visually "blink" some text fields in
          response to a button push?
          How do I replace the DoEvents functionality in a WPF application?
          >>
          >Are you referencing System.Windows. Forms.dll?
          >>
          >--
          >Tom Shelton- Hide quoted text -
          >>
          >- Show quoted text -
          >
          System.Windows. Forms is not listed in the available Namespaces under
          References in Project Properties.
          It wouldn't be unless you reference the dll - System.Windows. Forms.dll.
          I do not think that System.Windows. Forms can be referenced in a WPF
          application.
          Huh? You just need to referece System.Windows. Forms.dll. You can use
          Windows forms controls inside of a WPF app, so you most definately can
          reference the dll. You just have to add the reference manually.

          Of course, since this is a wpf app, using Application.DoE vents is
          probably not the right solution anyway...

          You might want to look here for a wpf implementation:

          http://shevaspace.spac es.live.com/blog/cns!FD9A0F1F8DD 06954!526.entry

          The code is C#, but, it should be a fairly simple conversion (the code
          is not very complex).

          I wonder if you can get your blink effect without using a sleep... Have
          you tried looking at the wpf animation support?

          --
          Tom Shelton

          Comment

          • Cor Ligthert[MVP]

            #6
            Re: Cant use DoEvents in WPF application

            Don,

            Why are you using a Ready To Marked version while the version is allready
            for quiet a while on the marked.

            Are you sure you use a non official released VS 2008 version, I have never
            seen that a RTM version was not released.
            VS 2008. Something is RTM as it is not *official* released.

            By the way, for the progam languages is VSTS exactly the same as every VS
            version, it has only tools extentions to be uses by teams.

            Cor

            "Don" <dbaechtel@gmai l.comschreef in bericht
            news:6a336d30-e77c-4f82-bf38-af82bed96d18@x3 0g2000hsd.googl egroups.com...
            >I have a WPF application in VB in VSTS 2008 RTM. I am trying to
            "blink" (momentarily clear) a field of data if the data is reloaded
            from the database to give the user some visual indication of the LOAD
            operation.
            >
            So on the LOAD button I clear the text fields, do
            mainCanvas.Upda teLayout( ), and the reload the text field from the
            database. But the text fields are not cleared long enough to see them
            blink.
            >
            So I add a Thread.Sleep(20 0) before reloading the text fields. Still
            no visual blink.
            >
            So I change the Sleep(200) to Sleep(2000), Still no visual blink.
            >
            So I attempt to add an Application.DoE vents so that the application
            gets a chance to repaint the screen. But when I attempt to add the
            "Imports System.Windows. Forms" for the DoEvents, the IDE says
            "System.Windows .Forms doesn't contain any public member(s) or cannot
            be found."
            >
            Apparently DoEvents can not be used in a WPF application because it is
            not a Windows Forms.
            >
            OK, so how do I get WPF to visually "blink" some text fields in
            response to a button push?
            How do I replace the DoEvents functionality in a WPF application?

            Comment

            • Don

              #7
              Re: Cant use DoEvents in WPF application

              On Mar 18, 2:21 pm, Tom Shelton
              <tom_shel...@YO UKNOWTHEDRILLco mcast.netwrote:
              On 2008-03-18, Don <dbaech...@gmai l.comwrote:
              >
              >
              >
              On Mar 18, 12:16 pm, Tom Shelton
              <tom_shel...@YO UKNOWTHEDRILLco mcast.netwrote:
              On 2008-03-18, Don <dbaech...@gmai l.comwrote:
              >
              I have a WPF application in VB in VSTS 2008 RTM. I am trying to
              "blink" (momentarily clear) a field of data if the data is reloaded
              from the database to give the user some visual indication of the LOAD
              operation.
              >
              So on the LOAD button I clear the text fields, do
              mainCanvas.Upda teLayout( ), and the reload the text field from the
              database. But the text fields are not cleared long enough to see them
              blink.
              >
              So I add a Thread.Sleep(20 0) before reloading the text fields. Still
              no visual blink.
              >
              So I change the Sleep(200) to Sleep(2000), Still no visual blink.
              >
              So I attempt to add an Application.DoE vents so that the application
              gets a chance to repaint the screen. But when I attempt to add the
              "Imports System.Windows. Forms" for the DoEvents, the IDE says
              "System.Windows .Forms doesn't contain any public member(s) or cannot
              be found."
              >
              Apparently DoEvents can not be used in a WPF application because it is
              not a Windows Forms.
              >
              OK, so how do I get WPF to visually "blink" some text fields in
              response to a button push?
              How do I replace the DoEvents functionality in a WPF application?
              >
              Are you referencing System.Windows. Forms.dll?
              >
              --
              Tom Shelton- Hide quoted text -
              >
              - Show quoted text -
              >
              System.Windows. Forms is not listed in the available Namespaces under
              References in Project Properties.
              >
              It wouldn't be unless you reference the dll - System.Windows. Forms.dll.
              >
              I do not think that System.Windows. Forms can be referenced in a WPF
              application.
              >
              Huh? You just need to referece System.Windows. Forms.dll. You can use
              Windows forms controls inside of a WPF app, so you most definately can
              reference the dll. You just have to add the reference manually.
              >
              Of course, since this is a wpf app, using Application.DoE vents is
              probably not the right solution anyway...
              >
              You might want to look here for a wpf implementation:
              >
              http://shevaspace.spac es.live.com/blog/cns!FD9A0F1F8DD 06954!526.entry
              >
              The code is C#, but, it should be a fairly simple conversion (the code
              is not very complex).
              >
              I wonder if you can get your blink effect without using a sleep... Have
              you tried looking at the wpf animation support?
              >
              --
              Tom Shelton
              A modified version of the code that you referenced from shevaspace
              worked just fine. I got the DoEvents and Blink functionality that I
              was looking for. THANK YOU VERY MUCH !!

              I wrote the two following routines in VB:

              Imports System.Windows. Threading
              Imports System.Threadin g
              Public Sub DoEvents()

              Application.Cur rent.Dispatcher .Invoke(Dispatc herPriority.Bac kground,
              New ThreadStart(Add ressOf doNothing))
              End Sub

              Public Sub doNothing()

              End Sub

              And then in my application the pseudo code goes:
              Public Sub OnLoadButton_Cl ick( )
              Clear TextFields
              DoEvents( )
              Fill TextFields from Database
              End Sub

              This gives me the "Blink" that I needed that visually shows Blank Text
              fields briefly before the Text fields are reloaded so that the User
              notices that something happened each time the LoadButton is clicked.

              It is frequently helpful to be able to force(allow) a screen update
              and a short time delay to occur before any remaining code is executed
              for purposes like this.

              This will be a helpful technique for many VB WPF developers.

              THANKS again for your help.

              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: Cant use DoEvents in WPF application

                "Cor Ligthert[MVP]" <notmyfirstname @planet.nlschri eb:
                Why are you using a Ready To Marked version while the version is allready
                for quiet a while on the marked.
                RTM <"Ready To Market". The RTM version is the version which is finally
                distributed (sent to the manufacturer who creates the CDs/DVDs).

                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                Comment

                • Cor Ligthert[MVP]

                  #9
                  Re: Cant use DoEvents in WPF application


                  ">Why are you using a Ready To Marked version while the version is
                  allready
                  >for quiet a while on the marked.
                  >
                  RTM <"Ready To Market". The RTM version is the version which is finally
                  distributed (sent to the manufacturer who creates the CDs/DVDs).
                  >
                  Yes and?

                  Cor

                  Comment

                  • Steve Gerrard

                    #10
                    Re: Cant use DoEvents in WPF application

                    Cor Ligthert[MVP] wrote:
                    ">Why are you using a Ready To Marked version while the version is
                    allready
                    >>for quiet a while on the marked.
                    >>
                    >RTM <"Ready To Market". The RTM version is the version which is
                    >finally distributed (sent to the manufacturer who creates the
                    >CDs/DVDs).
                    >
                    Yes and?
                    >
                    and it is therefore okay and good to use a RTM version...


                    Comment

                    • Cor Ligthert [MVP]

                      #11
                      Re: Cant use DoEvents in WPF application

                      >
                      and it is therefore okay and good to use a RTM version...
                      >
                      But there is no need to express that here

                      :-)

                      Cor


                      Comment

                      • Steve Gerrard

                        #12
                        Re: Cant use DoEvents in WPF application

                        Cor Ligthert [MVP] wrote:
                        >and it is therefore okay and good to use a RTM version...
                        >>
                        But there is no need to express that here
                        >
                        :-)
                        >
                        Cor
                        You asked the question: "Why are you using a Ready To Marked version while the
                        version is allready for quiet a while on the marked."

                        Therefore you got an answer.

                        By the way, RTM = Released to Manufacturing.


                        Comment

                        Working...