|
Where to start? ... How about formulating your question better? Did you mean "Search" or "Indexing"? Or?
Or is this your Dad's computer; and you're trying to hide your "browsing"?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Where can I get a monogame implementation of a snooker or pool game? I'm only 3 weeks into learning C# so no complicated answers 😉
|
|
|
|
|
Member 13545375 wrote: no complicated answers
Google.[^]
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Why, oh why didn't I think of that first? Hehehe.
I guess I'll just have to go about it the long way
|
|
|
|
|
You wanted "no complex answer"!
And there are no "simple" answers to simulating pool, snooker, or even billiards. Learning to plan the real game properly at a good quality can absorb huge amounts of your life, because tiny differences cause such massive changes: professional snooker players take years to get to that level, and have to practice 5 ~ 6 hours a day, 6 days a week to maintain, let alone improve their skills.
Simulating that? Not a trivial subject in any way, shape, or form - so there are no "no complex answers" other than "go to Google, and it will serve up some of the complicated ones".
Seriously, this isn't a task for a beginner - I wouldn't want to try it on my own and I've been coding for 30+ years! I'd need a team of developers, designers, and some professionals on standby to get any reasonable results in a workable time frame of 2 ~ 3 years. Even then, it probably wouldn't be ready for public release for another year or two after that. It's a big job!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That's like saying, "Where can I get a simple diagram of a Formula 1 engine, I have just learned how to assemble a 3-speed gear on my bike". And the issue really is not about C#, it is about the physics of ball trajectories on a pool/snooker table. Spend more (much more) time on some simple projects and learn as many .NET classes as possible first.
|
|
|
|
|
Formula one?!! #Horrified
|
|
|
|
|
Actually that was unfair of me, I have seen the bike taxis in Kasese district; those guys are cool.
|
|
|
|
|
I'm going to go one better and assemble a formula 1 engine from kiseka market spare parts
|
|
|
|
|
Don't forget to post a video of its first test run.
Member 13545375 wrote: kiseka market
We drove past there the day (in 2005) before we flew home, when our buses got stuck in a flood downtown.
|
|
|
|
|
Yeah, that's an area to avoid if you can... The city is almost proud to have it as some sort of "right of passage" for those who dare
|
|
|
|
|
Hello, I am trying to match a substring which contains the percent symbol using REGEX W character but it does not seem to work. Below is what I have so far.
string inputString = @"#Test{border-top:Solid blue 1px; border-bottom:1% solid black;}";
string escapedString = Regex.Escape("border-bottom");
string pattern = escapedString + @"\:\s?\d+\W(\s?\w+)*\;?\s?";
Regex rgx = new Regex(pattern);
Match match = rgx.Match(matchedCss);
string matchedString = match.Value;
Console.WriteLine(matchedString);
Console.ReadLine();
The REGEX pattern above should have matched the substring
border-bottom:1% solid black; but for some reason it did not. Please help me resolve this problem, thanks in advance.
modified 29-Nov-17 21:45pm.
|
|
|
|
|
You don't need to escape the colon maybe?
And probably not the semi-colon either?
And after all the begging I had to do to get Chris to add a Regular Expressions Forum[^] , too. 
|
|
|
|
|
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
pattern = escapedString + @":\s?\d+\W(\s?\w+)*\s?;?\s?";
modified 29-Nov-17 22:35pm.
|
|
|
|
|
It works for
string inputString = @"#Test{border-top:Solid blue 1px; border-bottom:1% solid black;}";
I put the code provided in VS and got:
Error 1 The name 'matchedCss' does not exist in the current context F:\Project\PlayGround\Playground\Form1.cs 757 56 Playground
So, what text are you actually trying to match?
|
|
|
|
|
ehm:
string inputString = @"#Test{border-top:Solid blue 1px; border-bottom:1% solid black;}";
string escapedString = Regex.Escape("border-bottom");
string pattern = escapedString + @"\:\s?\d+\W(\s?\w+)*\;?\s?";
Regex rgx = new Regex(pattern);
Match match = rgx.Match(inputString);
string matchedString = match.Value;
Console.WriteLine(matchedString);
It works for me. At least when I set the inputString to match you expression.
|
|
|
|
|
It is now working. It was driving me nuts, after everything failed I decided to restart Visual Studio and it started working.
|
|
|
|
|
Rule 1: Whenever a problem goes away on its own, it will come back on its own.
|
|
|
|
|
Means the code that you were looking at was not the code that was running.
Perhaps because it was running a prior build rather than with your updates.
|
|
|
|
|
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);
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.
|
|
|
|
|
You don't. The way you set it up, it's "fire and forget".
You've got the await in the wrong place. That should go on the callers side, not the function ...Async side. The Async method should return a Task. That lets the caller await the Task.
Something like this:
private Task<List<string>> GetUsersAsync()
{
return Task.Run(() =>
{
List<string> userList = new List<string>() {
"User1", "User2", "User3", "User4", "User5"
};
Thread.Sleep(5000);
return userList;
});
}
Then you can call it like this (very simple Windows Forms example):
private async void button1_Click(object sender, EventArgs e)
{
var users = await GetUsersAsync();
foreach (string user in users)
{
listBox1.Items.Add(user);
}
}
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.
C# - How to debug code[ ^].
Seriously, go read these articles.
Dave Kreskowiak
|
|
|
|
|
Thank you!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
var users = adHelper.ImportUsersAsync(basePath);
change in
var users = adHelper.ImportUsersAsync(basePath).Result;
|
|
|
|
|
That's not going to fix the problem at all and you're really not even changing the code. The .Result is implied in the original post.
System.ItDidntWorkException: Something didn't work as expected.
C# - How to debug code[ ^].
Seriously, go read these articles.
Dave Kreskowiak
|
|
|
|
|
No it is not implied... He is just assigning a non started Task to user.
As long as he doesnt await user() or user.Result... Then nothing ever happens with it.
|
|
|
|