Comment by Sinatr on Methods are being randomly called when space bar is pressed
If those conditions are exclusive, then simply replace if with else if (starting from second if). See tutorial.
View ArticleComment by Sinatr on How can I return A and b from this exponential fit...
Good, so the result was found and then method return 3 values, but only IObjectiveModel has chance to contain parameters (if they were somehow set by passing P and model together).
View ArticleComment by Sinatr on Difference between DispatchAsync and DispatchSync(async...
The first example is async void. You may need to create a blocking task running your lambda and wait for it, unless it's a fire-and-forget scenario.
View ArticleComment by Sinatr on Drawing a bounding box around UI Elements in Unity
For operations like this you don't want to have raw unprocessed images at hand. I am not sure if converting image to Sprite can help you. I guess sprites are designed for stuff like this, to perform...
View ArticleComment by Sinatr on Need help downgrading .NET version
Is app not working, refuse to install or what is the problem, due to which you decide to uninstall newer framework?
View ArticleComment by Sinatr on What exception should I throw when expecting a null value?
InvalidOperationException is the best to use standard exception, when work is started, but can't be completed. Your method is trying to get something, it didn't worked as it should, throw.
View ArticleComment by Sinatr on Loop directory to return multiple PDF Files
Don't return anything from inside the loop, rather save results of all iterations e.g. into a List and return after loop is finished.
View ArticleComment by Sinatr on C# add listener to external API property
Make minimal reproducible example and send bug report with not firing notification to developer. Until it's fixed use workarounds, e.g. use polling for detecting changes or use wrapper to rise missing...
View ArticleComment by Sinatr on Is here any best practices to debug multithreading...
You have to show where you stuck. I guess you are either looking at wrong address or not taking in account 64 bit system (pointers are 8 bytes).
View ArticleHow to deal with packages which install something into Assets folder?
Installing certain Unity packages will add something into Assets folder.Three examples of packages:ProBuilder will create a smallAssets\ProBuilder Data\Default Material Palette.assetTextMesh Pro will...
View ArticleAnswer by Sinatr for Is there a way to grab the actual state of System.Random?
To ensure the same initial sequence of random numbers upon new start (that's how OP tests it I guess) one can seed the new instance of Random with a number from previous Random.I guess f(rnd) (random...
View ArticleOverride default values for a game object
ProblemI have same problem like here: whenever I change default field value in the scriptpublic class SomeScript : MonoBehaviour{ public float someParameter = 30; // was 10 // changing value here will...
View ArticleMin() and Max() or single oldschool foreach?
If I have big collection and I care about performance, should I believe in miracle and usevar min = Y.Min();var max = Y.Max();or I better be a good engineer and usevar max = double.NegativeInfinity;var...
View ArticleWhere to unsubscribe from events?
E.g. for a general type, which subscribe to some events in constructor:class SomeType{ public SomeType(...) { someEvent1 += ... someEvent2 += ... }}Where do I unsubscribe from...
View ArticleThe specified value cannot be assigned to the collection
EditThis bugs me for an almost year. I'll update the answer and add bounty.I've custom control, which has dependency property public class Graph : Control{ public List<Figure> Figures { get {...
View ArticlePerformance issue when using ListView with columns and bindings
I have performance issue with ListView:Single item takes 13-30 ms to create (50 items is over 1 second). Virtualization (recyling mode) is on, but scrolling even 100 items is already very...
View ArticleAnswer by Sinatr for How to set the default user column sort in Avalonia's...
Just wanted to post an example, using the answer from @DrunkenCodeMonkey (upvote his answer).Code behind:public partial class SomeUserControlOrWindow: UserControl{ public SomeUserControlOrWindow() {...
View ArticleHow to use indexers in switch expression?
How to access indexers in switch expression? There is a nice property pattern syntax in switch expressions, but I can't figure out or find any information about using indexers.Given following code:var...
View ArticleAnswer by Sinatr for Best practice for TryGet method style
If you already have a method that throws, then it's easy to make a Try... variant of it using ... suprise! try/catch:public bool TryReturnSomething(..., out SomeType result) // ... - parameters{ try {...
View ArticleDoes `Property` path syntax supports casting in Avalonia, like in WPF?
Often in WPF we need to cast property to specific type to be able to access further properties in the path, e.g. from some...
View Article