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. WPF
  4. Application.Run C# equivalent

Application.Run C# equivalent

Scheduled Pinned Locked Moved WPF
csharpwpfquestion
17 Posts 4 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.
  • G GregJ7

    The present WPF equivalent of what used to be:

    BOOL bRet;

    while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
    {
    if (bRet == -1)
    {
    // handle the error and possibly exit
    }
    else
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #7

    That is Win32, not .NET, and the .NET equivalent is handled inside the framework.

    1 Reply Last reply
    0
    • G GregJ7

      That is,

      public class Application {
      private void Run() {

          // What code has Microsoft put here?
      
      }
      

      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #8

      GregJ7 wrote:

      // What code has Microsoft put here?

      You would have to ask Microsoft. Or buy an MSDN developer subscription which gives you access to their source code.

      1 Reply Last reply
      0
      • G GregJ7

        Where can I find a C# equivalent (code) for the WPF, Microsoft-hidden Application.Run method?

        G Offline
        G Offline
        GregJ7
        wrote on last edited by
        #9

        Has anyone that knows what WPF Application.Run() does written a C# function that duplicates what it does? Can you point me to that code? Thanks.

        L 1 Reply Last reply
        0
        • G GregJ7

          Has anyone that knows what WPF Application.Run() does written a C# function that duplicates what it does? Can you point me to that code? Thanks.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #10

          I already told you the answer. I also suggested that you explain what problem you are trying to solve.

          G 1 Reply Last reply
          0
          • L Lost User

            I already told you the answer. I also suggested that you explain what problem you are trying to solve.

            G Offline
            G Offline
            GregJ7
            wrote on last edited by
            #11

            Where did you tell me everything what Application.Run() does and how it does it? If you can't understand my question or don't know the answer to my question, then I would like an answer from someone who does.

            L 1 Reply Last reply
            0
            • G GregJ7

              Where did you tell me everything what Application.Run() does and how it does it? If you can't understand my question or don't know the answer to my question, then I would like an answer from someone who does.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #12

              I told you where to find the information. Whatever that method does is internal to Microsoft, so they are the people to answer the question. What you have still not done, is to explain exactly what problem (if you actually have one) you are trying to solve.

              1 Reply Last reply
              0
              • G GregJ7

                Where can I find a C# equivalent (code) for the WPF, Microsoft-hidden Application.Run method?

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #13

                You could always take a look at the publicly available[^] reference source code.

                This space for rent

                G 1 Reply Last reply
                0
                • P Pete OHanlon

                  You could always take a look at the publicly available[^] reference source code.

                  This space for rent

                  G Offline
                  G Offline
                  GregJ7
                  wrote on last edited by
                  #14

                  Tyvm!

                  P 1 Reply Last reply
                  0
                  • G GregJ7

                    Tyvm!

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #15

                    I'm old. That took me a minute to translate :) You are most welcome.

                    This space for rent

                    1 Reply Last reply
                    0
                    • G GregJ7

                      That is,

                      public class Application {
                      private void Run() {

                          // What code has Microsoft put here?
                      
                      }
                      

                      }

                      Richard DeemingR Offline
                      Richard DeemingR Offline
                      Richard Deeming
                      wrote on last edited by
                      #16

                      Reference Source[^]

                      public int Run()
                      {
                      EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordGeneral | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WClientAppRun);
                      return this.Run(null);
                      }

                      public int Run(Window window)
                      {
                      VerifyAccess();

                      //
                      // Browser hosted app should not explictly call App.Run(). We need to filter out those
                      // calls here
                      //
                      if (InBrowserHostedApp())
                      {
                          throw new InvalidOperationException(SR.Get(SRID.CannotCallRunFromBrowserHostedApp));
                      }
                      else
                      {
                          return RunInternal(window);
                      }
                      

                      }


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                      G 1 Reply Last reply
                      0
                      • Richard DeemingR Richard Deeming

                        Reference Source[^]

                        public int Run()
                        {
                        EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordGeneral | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WClientAppRun);
                        return this.Run(null);
                        }

                        public int Run(Window window)
                        {
                        VerifyAccess();

                        //
                        // Browser hosted app should not explictly call App.Run(). We need to filter out those
                        // calls here
                        //
                        if (InBrowserHostedApp())
                        {
                            throw new InvalidOperationException(SR.Get(SRID.CannotCallRunFromBrowserHostedApp));
                        }
                        else
                        {
                            return RunInternal(window);
                        }
                        

                        }


                        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                        G Offline
                        G Offline
                        GregJ7
                        wrote on last edited by
                        #17

                        Thanks. I found what I wanted in the Dispatcher class (which class Application uses). I needed to see more than I thought, because there is so much important code, however, what I originally was looking for was basically the following in Dispatcher.PushFrameImpl():

                        while(frame.Continue)
                        {
                        if (!GetMessage(ref msg, IntPtr.Zero, 0, 0))
                        break;

                        TranslateAndDispatchMessage(ref msg);
                        

                        }

                        From this code I was led to learn about thread Frames and such.

                        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