Click here to Skip to main content
15,884,388 members
Home / Discussions / C#
   

C#

 
GeneralRe: Active Directory UserPrincipal Extension not working Pin
Eddy Vluggen2-Nov-12 9:57
professionalEddy Vluggen2-Nov-12 9:57 
QuestionProtected Interface Members Pin
Ambika Jadhav1-Nov-12 20:22
Ambika Jadhav1-Nov-12 20:22 
AnswerRe: Protected Interface Members Pin
Richard MacCutchan2-Nov-12 0:46
mveRichard MacCutchan2-Nov-12 0:46 
AnswerRe: Protected Interface Members Pin
Abhinav S2-Nov-12 0:49
Abhinav S2-Nov-12 0:49 
AnswerRe: Protected Interface Members Pin
BobJanova2-Nov-12 0:55
BobJanova2-Nov-12 0:55 
AnswerRe: Protected Interface Members Pin
markovl2-Nov-12 1:44
markovl2-Nov-12 1:44 
GeneralRe: Protected Interface Members Pin
Ambika Jadhav4-Nov-12 16:09
Ambika Jadhav4-Nov-12 16:09 
QuestionWhy does this code hang? (async) Pin
SledgeHammer011-Nov-12 19:07
SledgeHammer011-Nov-12 19:07 
Why is this code hanging:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private int Test()
        {
            System.Diagnostics.Debug.WriteLine("IN");
            System.Threading.Thread.Sleep(5000);
            System.Diagnostics.Debug.WriteLine("OUT");
            return 17;
        }

        private async Task<int> TestAsync()
        {
            return await Task.Run(() =>
            {
                return Test();
            });
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("BEFORE");
            int a = TestAsync().Result;
            System.Diagnostics.Debug.WriteLine("AFTER");
        }
    }
}


If I don't return a value from the async function, this code works as I expect. BEFORE, IN, AFTER, <5 sec pause>, OUT.

Kind of trying to make an async function that returns a value without blocking the UI thread.
AnswerRe: Why does this code hang? (async) Pin
OriginalGriff1-Nov-12 22:24
mveOriginalGriff1-Nov-12 22:24 
GeneralRe: Why does this code hang? (async) Pin
SledgeHammer012-Nov-12 6:40
SledgeHammer012-Nov-12 6:40 
AnswerRe: Why does this code hang? (async) Pin
Eddy Vluggen2-Nov-12 2:00
professionalEddy Vluggen2-Nov-12 2:00 
QuestionWCF Windows Service with ASP.net Application authentication problem... Pin
JD861-Nov-12 11:37
JD861-Nov-12 11:37 
AnswerRe: WCF Windows Service with ASP.net Application authentication problem... Pin
JD861-Nov-12 11:48
JD861-Nov-12 11:48 
QuestionService Installer not generating the service exe file Pin
JD861-Nov-12 5:10
JD861-Nov-12 5:10 
AnswerRe: Service Installer not generating the service exe file Pin
JD861-Nov-12 5:18
JD861-Nov-12 5:18 
AnswerRe: Service Installer not generating the service exe file Pin
CafedeJamaica1-Nov-12 11:05
professionalCafedeJamaica1-Nov-12 11:05 
GeneralRe: Service Installer not generating the service exe file Pin
JD861-Nov-12 11:13
JD861-Nov-12 11:13 
QuestionBackup/Restore - SQL Compact Edition Pin
saturnuk31-Oct-12 22:47
saturnuk31-Oct-12 22:47 
AnswerRe: Backup/Restore - SQL Compact Edition Pin
Richard MacCutchan31-Oct-12 23:48
mveRichard MacCutchan31-Oct-12 23:48 
AnswerRe: Backup/Restore - SQL Compact Edition Pin
Simon_Whale1-Nov-12 0:47
Simon_Whale1-Nov-12 0:47 
GeneralRe: Backup/Restore - SQL Compact Edition Pin
saturnuk1-Nov-12 0:58
saturnuk1-Nov-12 0:58 
GeneralRe: Backup/Restore - SQL Compact Edition Pin
Eddy Vluggen1-Nov-12 1:55
professionalEddy Vluggen1-Nov-12 1:55 
GeneralRe: Backup/Restore - SQL Compact Edition Pin
GrooverFromHolland2-Nov-12 10:46
GrooverFromHolland2-Nov-12 10:46 
QuestionInfragistics Tree With Checkboxes Pin
Kevin Marois31-Oct-12 12:49
professionalKevin Marois31-Oct-12 12:49 
AnswerRe: Infragistics Tree With Checkboxes Pin
Pete O'Hanlon31-Oct-12 13:26
mvePete O'Hanlon31-Oct-12 13:26 

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.