Click here to Skip to main content
15,798,200 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I get "Failed to compare two elements in the array" error when I run the following code:
Private Sub BoyamaGradyan(args())
Dim args2count, args4count As Integer
DirectCast(args(0), Object).Dispatcher.Invoke(DirectCast(Sub()
                                                   args2count = args(2).count
                                                   args4count = args(4).count
                                                        End Sub, Action))
End Sub

This code runs under an external thread, that's why I copy args(2).count and args(4).count. Otherwise I cannot access them because they belong to the main thread.

args(2) and args(4) are GradientColorBrushes, args(0) is a label.
Here, you can see the types of all variables related to this issue:,PNG&authkey=!AHIEIyv1pPWscGA[^]

Error does not happen everytime I run this code. Happens only when I call this code again and again quickly even though I abort the thread when it's already running and called again. How can I get rid of it?

Thanks in advance

Edit: I have just realized that this error is also thrown when I call update() sub which I use to return results to the main thread. Therefore, I think this could be thrown at any Dispatcher.invoke sub I call
Updated 9-Apr-15 12:04pm

1 solution

Sorry for not enough information in question. I have solved it myself, and actually, solution is not really predictable looking at the code I've written above.
Problem is that some of the parameters are double type which stands for 64 bit floating binary point and I compiled it with 32 bit compiler. When these double's exceed 32 bits, program crushes. So the solution for this is to use single (float in C#) which stands for 32 bit floating binary point or to compile the program using 64 bit compiler.

Please tell me if I'm wrong or missing something..
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900