|
I think I'm getting closer. I found a change in Edge that says it no longer uses the Windows certs - but manages its own. It doesn't seem to pick up my/VS self-gen'ed dev cert. Going to try to figure out how to do a manual import and see if that helps.
|
|
|
|
|
How to get XSI:type in inner class while converting to XML
|
|
|
|
|
You already posted this question in Q&A. There's no need to post it again.
What you do need to do is provide more information about what it is that you're actually trying to do here. That question could mean many things and the solution will depend on what it is that you're trying to do here.
|
|
|
|
|
I want to run a these commands in parallel and get the results as each finishes.
private void Load()
{
_apiProxy.GetNavigationItems(NavigationItemType.Company);
_apiProxy.GetNavigationItems(NavigationItemType.Employee);
_apiProxy.GetNavigationItems(NavigationItemType.Project);
}
What's the right way to do this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 7-Apr-23 1:17am.
|
|
|
|
|
Why not use three separate await Task.Run commands in sequence?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I always thought await returns back to the caller, so at the first await, the rest are not fired until the previous one completed
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Sorry - I didn't see the "in parallel" bit in your original post.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
NP, so what's the best way to run them in parallel and wait for results from each one separatly?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
As in:
private void Bar()
{
Task.Run(() => { Thread.Sleep(2000); Console.WriteLine("1 done"); Thread.Sleep(2000); }).ContinueWith((x) => { Console.WriteLine("1 complete"); });
Console.WriteLine("one done");
Task.Run(() => { Thread.Sleep(2000); Console.WriteLine("2 done"); Thread.Sleep(2000); }).ContinueWith((x) => { Console.WriteLine("2 complete"); }); ;
Console.WriteLine("two done");
Task.Run(() => { Thread.Sleep(2000); Console.WriteLine("3 done"); Thread.Sleep(2000); }).ContinueWith((x) => { Console.WriteLine("3 complete"); }); ;
Console.WriteLine("all done");
}
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In this case you can just do:
var companyTask = _apiProxy.GetNavigationItems(NavigationItemType.Company);
var employeeTask = _apiProxy.GetNavigationItems(NavigationItemType.Employee);
var projectTask = _apiProxy.GetNavigationItems(NavigationItemType.Project);
var companies = await companyTask;
var employees = await employeeTask;
var projects = await projectTask;
Of course it is up to the apiProxy (or any method it calls) if it will actually run concurrently.
modified 7-Apr-23 8:29am.
|
|
|
|
|
Kevin Marois wrote: I want to run a these commands in parallel and get the results as each finishes.
First of course you need to figure out how exactly you are going to collect the results. Additional to that you might also consider what you are going to do with the results.
Collecting the results itself has nothing to do with running them in parallel but it does impact how you encapsulate what it is exactly that you want each 'task' to do.
For example if each task just returned a boolean and you wanted to return that to the caller then you need a structure that holds a boolean and something that tells you which task returned which boolean. It can get way more complicated than that. For example if each one returns data in a different format.
Probably a really good idea also to consider what happens if there is an error. Could be an expected error or an unexpected error.
|
|
|
|
|
Assuming you have a list of tasks which return the same type, and you want to process the task results in the order in which they complete, then Stephen Toub has you covered:
Processing tasks as they complete - .NET Parallel Programming[^]
For a small number of tasks, using Task.WhenAny is probably good enough:
var tasks = new List<Task<T>>
{
_apiProxy.GetNavigationItems(NavigationItemType.Company),
_apiProxy.GetNavigationItems(NavigationItemType.Employee),
_apiProxy.GetNavigationItems(NavigationItemType.Project)
};
while (tasks.Count != 0)
{
var t = await Task.WhenAny(tasks);
tasks.Remove(t);
T result = await t;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
How can I have a regex for my .NET app's user password with the following:
Password MUST be a minimum of 10 AND maximum of 50
It should NOT contain space.
It should be MIXED alphabet (upper + lower), numeric and following special characters !@#$%^&*-_+=~
Thanks,
Jassim
www.softnames.com
|
|
|
|
|
RegEx is not a good fit for password rules. You'd be much better off coding each rule separately.
|
|
|
|
|
The problem with using a regex for this is that it gets very, very complex - and that means that when the rules change (and they always do) a horribly complicated and difficult to understand string has to be modified, tested, fixed, tested, and finally released. Which makes maintenance difficult and prone to error.
Instead, use .NET string operations (or individual Regexes) to pick up each individual part:
int numLoCase = ...
int numUpCase = ...
int numSpaces = ...
int numNumeric = ...
int numSpecial = ...
int len = ... And then apply a single if statement to apply the rules:
if (len >= 10
&& len <= 50
&& numSpaces == 0
&& ... You get much more readable code, and more reliable maintenence.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Jassim Rahma wrote: Password MUST be a minimum of 10 AND maximum of 50
It should NOT contain space.
It should be MIXED alphabet (upper + lower), numeric and following special characters !@#$%^&*-_+=~ Tell management to f*** off.
A horse staple is better. Let's do a Zoom where I can explain that fine detail. I will be recording for training purposes only.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
probe the next function:
bool IsValidPassword(string password,
int minLength=10,
int maxLength=50,
bool requireLowercase=true,
bool requireUppercase=false,
bool requireNumber=false,
bool requireSimbol=false)
{
if (string.IsNullOrEmpty(password))
{
return false;
}
if (password.Length < minLength || password.Length > maxLength)
{
return false;
}
if (requireUppercase && !Regex.IsMatch(password, "[A-Z]"))
{
return false;
}
if (requireLowercase && !Regex.IsMatch(password, "[a-z]"))
{
return false;
}
if (requireNumber && !Regex.IsMatch(password, "[0-9]"))
{
return false;
}
string pattern= @"[!@#$%^&*()_+\-=\[\]{};':" + "\"" + @"\\|,.<>\/? ~]";
if (requireSimbol && !Regex.IsMatch(password, pattern))
return false;
return true;
}
|
|
|
|
|
What's a simbol?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
Apart from the above-mentioned problem with the readability of Regex, another problem is that Regex is quite computation-heavy, and due to the fact that it builds underlying state-machine[^] performance penalty is heavier for big strings.
|
|
|
|
|
Hi All,
I want to create my own unit testing framework using C#.
Can anybody please suggest me any websites or articles for creating our own unit testing framework using C#.
Thank you All
|
|
|
|
|
Why? Visual Studio includes a UT framework already ... you are reinventing the wheel and adding a layer of possible bugs to the testing environment as well as spending some considerable time developing what already exists.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I doubt such a thing exists.
The idea itself is fairly obvious so I am not sure what you would need to know other than having used one at one time.
Now lets say you want to hook it into VS itself. That is not trivial. But you can't do that until you create the rest of it anyways.
Best thing I can suggest it so look at source code for log4net. And maybe read through questions and bugs for that.
|
|
|
|
|
Yes ... go for NUnit2. NUnit4.
NUnit.org
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|