New answers tagged

2

Regarding your validations - extract each of your validations in validation object. You can do something like: class Validator { isValid(obj) { //return false if obj is not valid } message(obj) { //return error object if obj is not valid } status() { //error status if validation fails } } Then you can have like EmailValidator, Required, etc. ...


4

Invoke is a blocking call that returns only after that call has competed. That means your loop is also including the time it takes to marshal over to the GUI thread and complete. You probably don't want that. I would use BeginInvoke instead, which does not wait for the method to complete on the GUI thread. This is also the difference between ...


4

Starting with the first function, I would make a few changes: Task.IsCompleted covers all completion states already (https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.iscompleted?view=netframework-4.8) Tasks are all about not blocking the current thread. Never use Thread.Sleep and always use Task.Delay. Cancellation can be more ...


Top 50 recent answers are included