Click here to Skip to main content
15,510,057 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 6:36
professionalRichard Andrew x641-Aug-20 6:36 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
arnold_w1-Aug-20 7:07
arnold_w1-Aug-20 7:07 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 7:10
professionalRichard Andrew x641-Aug-20 7:10 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
arnold_w1-Aug-20 7:15
arnold_w1-Aug-20 7:15 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 7:21
professionalRichard Andrew x641-Aug-20 7:21 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
arnold_w1-Aug-20 7:51
arnold_w1-Aug-20 7:51 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 8:05
professionalRichard Andrew x641-Aug-20 8:05 
QuestionAzure Active Directory question Pin
pkfox31-Jul-20 1:50
professionalpkfox31-Jul-20 1:50 
Hi all I have this method in a class which tries to get an access token from Azure Active Directory - it works if I use it in a Net Core app but hangs forever when I try to use it in a Winforms app
C#
private async Task GetAccessToken()
       {
            // Utils.GetAppConfigSetting just reads keys in App.config
           string Instance = Utils.GetAppConfigSetting("Instance");
           string TenantID = Utils.GetAppConfigSetting("TenantID");
           string ClientID = Utils.GetAppConfigSetting("ClientID");
           string ClientSecret = Utils.GetAppConfigSetting("ClientSecret");
           string BaseAddress = Utils.GetAppConfigSetting("BaseAddress");
           string ResourceID = Utils.GetAppConfigSetting("ResourceID");
           string APIServer = Utils.GetAppConfigSetting("APIServer");
           string Authority = String.Format(CultureInfo.InvariantCulture,Instance, TenantID);

           this.App = ConfidentialClientApplicationBuilder.Create(ClientID)
               .WithClientSecret(ClientSecret)
               .WithAuthority(new Uri(Authority))
               .Build();

           this.ResourceIds = new string[] { ResourceID };

           // this is where it hangs !!
           this.Result = await this.App.AcquireTokenForClient(this.ResourceIds).ExecuteAsync();
           this.AccessToken = this.Result.AccessToken;

           // this.Client is a RestSharp client
           this.Client.Authenticator = new JwtAuthenticator(this.AccessToken);
       }
// I call it with this code
this.GetAccessToken().GetAwaiter().GetResult();

there is no error it just hangs - any ideas ?

Edit

It must be the UI thread in Winforms as I just tried the same code in a Console App and it worked perfectly
"We can't stop here - this is bat country" - Hunter S Thompson - RIP


modified 31-Jul-20 9:51am.

AnswerRe: Azure Active Directory question Pin
Richard Deeming4-Aug-20 1:01
mveRichard Deeming4-Aug-20 1:01 
GeneralRe: Azure Active Directory question Pin
pkfox4-Aug-20 4:36
professionalpkfox4-Aug-20 4:36 
GeneralRe: Azure Active Directory question Pin
Richard Deeming4-Aug-20 4:40
mveRichard Deeming4-Aug-20 4:40 
GeneralRe: Azure Active Directory question Pin
pkfox4-Aug-20 6:38
professionalpkfox4-Aug-20 6:38 
GeneralRe: Azure Active Directory question Pin
Richard Deeming4-Aug-20 6:48
mveRichard Deeming4-Aug-20 6:48 
GeneralRe: Azure Active Directory question Pin
pkfox4-Aug-20 7:52
professionalpkfox4-Aug-20 7:52 
GeneralRe: Azure Active Directory question Pin
Richard Deeming5-Aug-20 0:14
mveRichard Deeming5-Aug-20 0:14 
GeneralRe: Azure Active Directory question Pin
pkfox5-Aug-20 4:12
professionalpkfox5-Aug-20 4:12 
GeneralRe: Azure Active Directory question Pin
pkfox5-Aug-20 0:12
professionalpkfox5-Aug-20 0:12 
QuestionHow to change the aspect ratio of an Windows media player by using C# Pin
Member 1488657531-Jul-20 1:25
Member 1488657531-Jul-20 1:25 
AnswerRe: How to change the aspect ratio of an Windows media player by using C# Pin
Gerry Schmitz31-Jul-20 8:32
mveGerry Schmitz31-Jul-20 8:32 
QuestionName Generator Pin
Brandnoob30-Jul-20 9:04
Brandnoob30-Jul-20 9:04 
AnswerRe: Name Generator Pin
Gerry Schmitz30-Jul-20 9:10
mveGerry Schmitz30-Jul-20 9:10 
AnswerRe: Name Generator Pin
OriginalGriff30-Jul-20 9:55
mveOriginalGriff30-Jul-20 9:55 
QuestionExecuteScalar to cshtml view Pin
Member 1490312930-Jul-20 6:30
Member 1490312930-Jul-20 6:30 
AnswerRe: ExecuteScalar to cshtml view Pin
Gerry Schmitz30-Jul-20 9:02
mveGerry Schmitz30-Jul-20 9:02 
GeneralRe: ExecuteScalar to cshtml view Pin
Member 1490312930-Jul-20 12:42
Member 1490312930-Jul-20 12:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.