LessThanDot Site Logo

LessThanDot

A decade of helpful technical content

This is an archive of the posts published to LessThanDot from 2008 to 2018, over a decade of useful content. While we're no longer adding new content, we still receive a lot of visitors and wanted to make sure the content didn't disappear forever.

Why do we need error handling?

Why do we need error handling?  Error handling is something that is often forgot or misunderstood or put off until something goes awry and we try to back peddle and retro fit the error handling logic in the script, stored procedure or function.  I think there are quite a few reasons we should engage in handling something other than the happy path of logic. I’ve listed a few here and I’m sure you can think of some more.

Read More...

Parallel.For and a difference between C# and VB.Net

While writing my last 2 blogposts I noticed that the Parallel.For was kinda better in C# than the VB.Net version. This is what I had in VB.Net. Edit vbnet Parallel.For(0, 5, Sub(b) CheckOnline(b) End Sub) Which would be this in C# csharp Parallel.For(0, 5, b => {CheckOnline(b)}); or the slightly shorter versions. vbnet Parallel.For(0, 5, Sub(b) CheckOnline(b)) Which would be this in C# csharp Parallel.For(0, 5, b => CheckOnline(b)); End Edit.

Read More...

Multithreaded ping shown in a grid C# version

Since I don’t want my dear friend Ted to do this himself I converted the code in my previous post into C#. I also wrapped the ping in a using statement and now only swallow InvalidOperationException because catching Exception is not good. using System; using System.Collections.Generic; using System.Drawing; using System.Net.NetworkInformation; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace mutlithreadedping { public partial class Form1 : Form { private List<int> _success = new List<int>(); private List<int> _done = new List<int>(); private Thread _fThread; private Thread _fThread2; private delegate void AddRowDelegate(int column); private delegate void SetOnlineDelegate(int rowindex); private void Form1_Load(object sender, EventArgs e) { fGrid.

Read More...

Multithreading pings and showing them in a grid in VB.Net

Today I wanted a way to see which of my cameras were online at a certain point in time. Pinging them is a great way of doing that, it at least says they are there and the first two layers of the OSI model are working (if I remember correctly). Doing a ping to another computer in VB.Net is easy. Dim _ping As New Ping Dim _pingreply = _ping.Send(IpAddress, 2000) If _pingreply.

Read More...

Silverlight 5 Beta Is Available For Download

Silverlight 5 Beta is available for download These are the top beta features XAML Debugging with breakpoints for binding debugging Implicit data templates for easy UI reuse Double (and multi) click support GPU-accelerated XNA-compatible 3D and immediate-mode 2D API Low-latency sound effects and WAV support Real operating system windows and multi-display support Significant performance improvements, fixes and much more More info about new features here: http://www.microsoft.com/silverlight/future/ There are also these items for download

Read More...

First Look at IE 10

Channel 9 has made available a video on their site about Internet Explorer 10, I have embedded the video here Here is what they say on the channel 9 site Just when you were expecting to hear more about IE9 on this opening day of Mix ‘11, and today we’ll be talking about the IE10 Platform Preview. IE10 builds on IE9 with support for even more standards like CSS3 gradients, multi-column, and grid layouts.

Read More...

NuGet stats

If you don’t know NuGet, then you are missing out. NuGetis a package downloader ala gems in the ruby world. There is also the package explorer by dotnetjunky to browse through the packages. This is fun and it has some stats too. Looking at the stats we can see which opensource projects are very popular and perhaps worth a look if you don’t know them yet. These are the first 15.

Read More...

Cycle Detection in F# – Fun With Immutability

I’ve been going through a lot of the problems from Project Euler in F#, and finding myself needing to change my way of thinking more and more often. I recently finished doing one problem that required use of a Cycle Detection algorithm, and as the solution evolved I thought it would be a good example of writing immutable code. Algorithm Being Examined For the example, I’ll use Brent’s variation on the tortoise-and-hare algorithm described at the link because it’s a little shorter.

Read More...

Get weekly transactions showing Monday's date

This recent MSDN thread presented an interesting, I believe, question: For a predefined set of the Application IDs show the weekly transactions and display Monday’s day for each week. The interesting twist in this common PIVOT query is to display a Monday’s date for a week. Rather than showing a solution for that particular thread, I show an AdventureWorks sample query. This query will return top 5 total amounts for each week by Customer (using SalesOrderHeader table).

Read More...

When changing column data types use ALTER TABLE TableName ALTER Column syntax, don't drop and recreate column

Someone asked how to change the data type from datetime to datetime2 Here is the question I have a SQL Server 2005 database with a datetime column. There is already data in the table but now the customer needs dates before 1753. So I decided to migrate the database to a SQL Server 2008 to use the datetime2 type. However I can’t just switch the type of the column from datetime to datetime2.

Read More...