Hi, thanks for your reply. I have updated my pattern by eliminating the back slash in front of the colon and semicolon as you have suggested. However, it still does not work. Below is the updated pattern
publicasync Task<List<ActiveDirectoryUser>> ImportUsersAsync(string basePath)
returnawait 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();
user.DisplayName = (string)result.Properties["displayname"];
user.LoginName = (string)result.Properties["samaccountname"];
foreach (var prop in result.Properties)
DictionaryEntry de = (DictionaryEntry)prop;
ResultPropertyValueCollection rpvc = (ResultPropertyValueCollection)de.Value;
now, when i run it:
ActiveDirectoryHelper adHelper = new ActiveDirectoryHelper();
var users = adHelper.ImportUsersAsync(basePath); // This is asyncvar user = adHelper.GetUserInfo(serverName, userName);
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.
Then you can call it like this (very simple Windows Forms example):
privateasyncvoid button1_Click(object sender, EventArgs e)
// The await just says "Put a bookmark here and return from the method until the Task returns". // In this simple Windows Forms example, the code will go back to processing the message pump, // keeping the UI alive.var users = await GetUsersAsync();
// When the Task returns, the code will resume here and show the list that was returned.foreach (string user in users)
Is this production quality code? NO! It's meant to be a simple example demonstrating Task/Async/Await. It doesn't handle exceptions and doesn't make sure the Click handler doesn't get called again while the first Task is still running.
System.ItDidntWorkException: Something didn't work as expected.
I am working on Simple injector DI framework. I need good ideas on how to register interface which is consumed in more than one provider (component).
Below is my requirement.
It is WebAPI project where I have a BaggageController class which will get a request for Add Baggage operation, Based on a provider from the request I have to route the request to concerned class. A Provider can be an Airline A or Airline B.
Request for AddBaggage(BaggageRequest, Provider) from client
--> BaggageController --> Business.Baggage.Implementation (Decision) --> Call Provider A
--> Call Provider B
Below is the code I am registering with Simple injector.
container.Register<iflightservice, providerb="">(Lifestyle.Scoped); --> This line throws an error as IFlightService is already registered.
Since my decision would be taken at runtime, I can not use the RegisterConditional method.
Is there any other way to register dependency at runtime using simple injector?