Run a task for two seconds without blocking the user interface

I'm writting a VB.Net app that interacts with a CAN bus in order to control some motors that are on it. With the CAN bus I can turn on and off each motor, in normal and reverse mode, and read their current consumption. I have implemented two checkbox

Convert datatable to xml with a unique ID line

I am converting datatable into xml. DataSet dataSet1 = new DataSet("Products"); products.TableName = "Product"; dataSet1.Tables.Add(products); dataSet1.WriteXml(directory + "//matrix.xml"); The code is working fine. I just wa

C # Override with different settings?

Here is an example of what I am looking to do. public class A { public virtual void DoSomething(string a) { // perform something } } public class B : A { public Override void DoSomething(string a, string b) { // perform something slightly different u

Is File.Exists considered harmful?

I often use library functions like File.Exists to check for a file's existence before opening it or doing some other action. While I have had good luck with this in practice over the years, I wonder if it is a poorly thought-out pattern. Any IO call

Applying Non-MVC Attributes to MVC Actions

Our application has the notion of a PermissionAttribute. This attribute is defined in a base layer of our application and our commands and queries are decorated with that attribute. Since this attribute is defined in base layer we can't (and don't wa

Is there a VB.NET expression that * always * returns null?

We all know that VB's Nothing is similar, but not equivalent, to C#'s null. (If you are not aware of that, have a look at this answer first.) Just out of curiosity, I'd like to know the following: Is there a VB.NET expression that always yields null?

Recursive summary ToString () in base class?

Look at the following (pseudo) pattern: public abstract class Animal { public abstract AnimalType { get; } public abstract override string ToString() { return String.Format("{0}={1}", AnimalType, this.ToString()); ^ // does this even work? } } w

Bon System.Object Round trip?

Using the Newtonsoft.Json library, imagine I have got public class Test { public Object Obj { get; set; } } Now, attempting to serialize this like so var json = JsonConvert.SerializeObject(new Test(){ Obj = new Uri(@"") });

.NET - Trace the print stack with variables

To improve application error handling I would like to log exceptions stack traces and variables values of each stack level. I've searched for Reflection but couldn't find anything. How can I see the variables?Without using additional tools (such as c

Wrap a Start () method and a Completed event in a task

I am migrating an application from Silverlight to Windows 8 and I wanted to take advantage of the System.Theading.Tasks API. I have a number of classes that have a Start() method and fire off a Completed event when they are done. Would anyone know ho

Determine if a service is already installed

As part of installing my windows service I have coded an alternative to installutil and the command line: IDictionary state = new Hashtable(); using (AssemblyInstaller inst = new AssemblyInstaller(typeof(MyServiceClass).Assembly, args)) { IDictionary

NHibernate and Repository Template

What is the recommended approach to take with Nhibernate + Repository pattern? There are so many different articles and opinions around that I am not sure what path to take. Take this lengthy article, for example. It gives an example of Query objects

Add two .NET SqlDecimals increases accuracy?

in .NET, when I add two SqlDecimals, like so: SqlDecimal s1 = new SqlDecimal(1); SqlDecimal s2 = new SqlDecimal(1); SqlDecimal s3 = s1 + s2; then s3 has precision 2, whereas both s1 and s2 have precision 1. This seems odd, especially as the documenta

limited check the CheckBox in C #

I made a win form and give some checkboxes that show the courses avilable for the student and by checing the checkbox he will able to tell that which courses he want to do but i want to restirct him when he check the three courses and if he try to ch

Support ideas for php on .net

I am a newly graduated programmer. I have done many web pages and services with Php. I took a project as a freelancer. My employer want the web site to be coded mainly with Php. He took another employee as a iphone developer. iphone developer guy wan

Is there AzMan 64bit?

Is there 64 bit version of AzMan? We have an app that uses Microsoft.Interop.Security.AzRoles.dll.Is there a 64 version of this ?I'm not sure about Windows 7 as I don't have a box to check but as far as Server 2008 R2 goes, the answer you're looking

NullReferenceException on this simple C # code

This question already has an answer here: What is a NullReferenceException, and how do I fix it? 33 answers Edit: The line of code that gives the exception is "foreach (Column column in table.Columns) " and that's because the Table table object

C # fails to parse NaN as a double

On a Windows PC in Japan, this line of C# throws a format exception: double d = double.Parse("NaN"); This line executes fine on my PC in the U.S. Don't know where to begin troubleshooting this one. Any thoughts? Thanks in advance, JimI see what

.Net SDK problem, which way to go?

We're writing an SDK for a CAD program and have run into a slight disagreement regarding a specific type of function (not just disagreement between different people, also disagreement between my two brain-halves). Imagine there's a lot of classes for

Defining DefaultValue for Non-Constant Type Properties?

I have a Windows.Forms component which has a "mySize" property that returns a Size struct. My intention was to have this property calculate the returned mySize automatically based on the size of the component, unless mySize has been explicity se

How to use the scroll trackpad in .Net

My WinForms app uses the mouse wheel, subscribing to the Control.MouseWheel event. How can I get it to work with scrolling methods from other input devices, in particular "finger along the edge" scrolling on the (Synaptics) trackpad on my T61? I

General location of the MVC

In the MVC folder structure, where should general class files reside? For example, I have a class that determines the right DataContext to use, so I'm not reinventing the wheel in each of my controllers. Should it live in the Controllers folder even

List of .NET attributes

Is there a list somewhere on common Attributes which are used in objects like Serializable? Thanks Edit ~ The reason I asked is that I came across an StoredProcedure attribute in ntiers ORMS.Yes, look msdn has you covered please look here. EDIT: This