Application.Run C# equivalent
-
Where can I find a C# equivalent (code) for the WPF, Microsoft-hidden Application.Run method?
-
That web page does not have the C# code equivalent of WPF's Application.Run() method. i.e., with a loop with GetMessage, DispatchMessage, etc.
-
As far as I can see it is the same, the difference being that it starts a Windows.Forms application, rather than a WPF one. You need to give more details of your actual problem.
-
As far as I can see it is the same, the difference being that it starts a Windows.Forms application, rather than a WPF one. You need to give more details of your actual problem.
-
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);
}
} -
That is,
public class Application {
private void Run() {// What code has Microsoft put here? }
}
-
Where can I find a C# equivalent (code) for the WPF, Microsoft-hidden Application.Run method?
-
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.
-
I already told you the answer. I also suggested that you explain what problem you are trying to solve.
-
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.
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.
-
Where can I find a C# equivalent (code) for the WPF, Microsoft-hidden Application.Run method?
You could always take a look at the publicly available[^] reference source code.
This space for rent
-
You could always take a look at the publicly available[^] reference source code.
This space for rent
-
I'm old. That took me a minute to translate :) You are most welcome.
This space for rent
-
That is,
public class Application {
private void Run() {// What code has Microsoft put here? }
}
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
-
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
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.