Solved: The destination thread no longer exists exception – C#

2016-11-08 You will get System.ComponentModel.InvalidAsynchronousStateException (The destination thread no longer exists.) if a UI component gets disposed or the UI thread EXITs while a different thread is in the middle of invoking a change on the same UI component. This usually happens when a user closes a window (form) that has been updated by aContinue reading “Solved: The destination thread no longer exists exception – C#”

C# Reflection Code to Search Objects for Fields Properties and Methods and Get Values

2016-07-06 Code below will search for a given named property, field, or method inside a given object. It will search in below order: Properties Fields Methods It will continue to search until it finds a match that holds or returns (for methods) a non-null value. E.g. If you searched for “Name” and if there is a propertyContinue reading “C# Reflection Code to Search Objects for Fields Properties and Methods and Get Values”

ILT – How to Programmatically Get Version Information of a Visual Studio Solution

03-10-2012 How to get major, minor, build and revision version figures for a visual studio solution (using c#)? Menol ILT    

Is Order Of OleDbCommand.Parameters Important

01-08-2012 The order of the parameters collection of an OleDbCommand must match the order to which those parameters appear in the SQL statement. Otherwise the .net framework will try to fill the parameters in your SQL statement according to the order of parameters in the OleDbCommand.Parameters collection. This can cause an Data type mismatch inContinue reading “Is Order Of OleDbCommand.Parameters Important”

How To Exit or End a C Sharp (C#) Application

12-06-2012 To exit a c# program simply use following command: Environment.Exit(int Status); Status is the integer you return to tell the environment how your program concludes. If it executed according as expected or if it encountered any errors. The commonly used success value is zero 0 This will mean that your program termintaes without anyContinue reading “How To Exit or End a C Sharp (C#) Application”

How to Implement a Background Worker Thread that Supports Cancellation (How to Stop A Background Thread)

30-05-2012 The background worker in .net provides a method CancelAsync() to cancel a background worker. However, calling this method will not stop a worker thread there has to be several things you have to implement before. 1. First of all, for a BackgroundWorker to respond to a CancelAsync, you must set the WorkerSupportsCancellation flag. 2.Continue reading “How to Implement a Background Worker Thread that Supports Cancellation (How to Stop A Background Thread)”

Use of “as” keyword as for casting in C#

2009-01-06 The keyword as doesn’t throw an exception if it fails to complete the casting operation. Instead it will return null. Other casting operations will throw an exception when the provided value cannot be casted. Since the “as” keyword sets or returns “null” value when it fails, the variable you use must be of aContinue reading “Use of “as” keyword as for casting in C#”

How to use LIKE operator in Dataview.RowFilter for Date Time or Numaric Fields using CONVERT

2012-01-16 // http://pagead2.googlesyndication.com/pagead/show_ads.js The RowFilter property of the DataView allows to use flexible string similar to SQL or LINQ to easily filter rows wihtout having to iterate through them. I had to implement a fully flexible search module for a project I’m working on. The user had to be able to perform a string searchContinue reading “How to use LIKE operator in Dataview.RowFilter for Date Time or Numaric Fields using CONVERT”