Click here to Skip to main content
15,792,771 members
Home / Discussions / C#
   

C#

 
GeneralRe: Matching Percent Symbol Using REGEX Pin
PIEBALDconsult29-Nov-17 17:12
professionalPIEBALDconsult29-Nov-17 17:12 
GeneralRe: Matching Percent Symbol Using REGEX Pin
Liagapi29-Nov-17 17:27
Liagapi29-Nov-17 17:27 
GeneralRe: Matching Percent Symbol Using REGEX Pin
PIEBALDconsult29-Nov-17 17:46
professionalPIEBALDconsult29-Nov-17 17:46 
AnswerRe: Matching Percent Symbol Using REGEX Pin
Kenneth Haugland29-Nov-17 17:31
professionalKenneth Haugland29-Nov-17 17:31 
GeneralRe: Matching Percent Symbol Using REGEX Pin
Liagapi29-Nov-17 18:02
Liagapi29-Nov-17 18:02 
GeneralRe: Matching Percent Symbol Using REGEX Pin
PIEBALDconsult29-Nov-17 18:06
professionalPIEBALDconsult29-Nov-17 18:06 
GeneralRe: Matching Percent Symbol Using REGEX Pin
jschell1-Dec-17 8:48
jschell1-Dec-17 8:48 
QuestionHow To Make This Async [UPDATED] Pin
Kevin Marois29-Nov-17 7:03
professionalKevin Marois29-Nov-17 7:03 
public async Task<List<ActiveDirectoryUser>> ImportUsersAsync(string basePath)
{
    return await Task.Run(() =>
    {
        List<ActiveDirectoryUser> users = new List<ActiveDirectoryUser>();

        var rootEntry = new DirectoryEntry(basePath);
        var searcher = new DirectorySearcher(rootEntry);
        SearchResultCollection results = searcher.FindAll();

        if (results != null)
        {
            foreach (SearchResult result in results)
            {
                ActiveDirectoryUser user = new ActiveDirectoryUser();
                if (result.Properties.Contains("displayname"))
                {
                    user.DisplayName = (string)result.Properties["displayname"][0];
                    user.LoginName = (string)result.Properties["samaccountname"][0];

                    foreach (var prop in result.Properties)
                    {
                        DictionaryEntry de = (DictionaryEntry)prop;
                        ResultPropertyValueCollection rpvc = (ResultPropertyValueCollection)de.Value;
                        user.Properties.Add(de.Key.ToString(), rpvc[0].ToString());
                    }

                    users.Add(user);
                }
            }
        }

        return users;

    });
}
now, when i run it:
ActiveDirectoryHelper adHelper = new ActiveDirectoryHelper();

var users = adHelper.ImportUsersAsync(basePath);    // This is async

var user = adHelper.GetUserInfo(serverName, userName);

Console.WriteLine("Done");

How can I know when the async method finished?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 29-Nov-17 12:17pm.

AnswerRe: How To Make This Async [UPDATED] Pin
Dave Kreskowiak29-Nov-17 15:42
mveDave Kreskowiak29-Nov-17 15:42 
GeneralRe: How To Make This Async [UPDATED] Pin
Kevin Marois30-Nov-17 5:19
professionalKevin Marois30-Nov-17 5:19 
AnswerRe: How To Make This Async [UPDATED] Pin
Member 1351776130-Nov-17 3:36
Member 1351776130-Nov-17 3:36 
GeneralRe: How To Make This Async [UPDATED] Pin
Dave Kreskowiak30-Nov-17 5:31
mveDave Kreskowiak30-Nov-17 5:31 
GeneralRe: How To Make This Async [UPDATED] Pin
Alex Schunk8-Jan-18 9:04
Alex Schunk8-Jan-18 9:04 
GeneralRe: How To Make This Async [UPDATED] Pin
Alex Schunk8-Jan-18 9:01
Alex Schunk8-Jan-18 9:01 
QuestionSimple Injector and Strategy pattern (Register dependency runtime based on request) Pin
nikunjmochi29-Nov-17 3:02
nikunjmochi29-Nov-17 3:02 
AnswerRe: Simple Injector and Strategy pattern (Register dependency runtime based on request) Pin
Eddy Vluggen29-Nov-17 3:26
professionalEddy Vluggen29-Nov-17 3:26 
GeneralRe: Simple Injector and Strategy pattern (Register dependency runtime based on request) Pin
nikunjmochi29-Nov-17 3:34
nikunjmochi29-Nov-17 3:34 
GeneralRe: Simple Injector and Strategy pattern (Register dependency runtime based on request) Pin
Eddy Vluggen29-Nov-17 3:52
professionalEddy Vluggen29-Nov-17 3:52 
QuestionUsing Reflection Pin
Mycroft Holmes28-Nov-17 15:21
professionalMycroft Holmes28-Nov-17 15:21 
GeneralRe: Using Reflection Pin
PIEBALDconsult28-Nov-17 15:30
professionalPIEBALDconsult28-Nov-17 15:30 
AnswerRe: Using Reflection Pin
User 740747028-Nov-17 17:28
User 740747028-Nov-17 17:28 
GeneralRe: Using Reflection Pin
Mycroft Holmes29-Nov-17 0:02
professionalMycroft Holmes29-Nov-17 0:02 
GeneralRe: Using Reflection Pin
User 740747029-Nov-17 0:37
User 740747029-Nov-17 0:37 
AnswerRe: Using Reflection Pin
BillWoodruff30-Nov-17 1:35
professionalBillWoodruff30-Nov-17 1:35 
GeneralRe: Using Reflection Pin
Mycroft Holmes30-Nov-17 13:01
professionalMycroft Holmes30-Nov-17 13:01 

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.