Skip to main content

164 posts tagged with "tech"

View All Tags

Threading and Waiting with Delegates

· 3 min read

One of the casualties of not having a full computer science education is that I was barely exposed to threading. In my two Java classes we touched upon it, and wrote some basic examples in the second semester, but that could hardly be called extensive use. Thus, a number of years on, it has been a bit of a struggle for me to use threads in a practical manner. Further complicating the matter is that I've wanted to use anonymous methods (aka delegates) and generally want to do some work after all threads have finished executing.

Windows Keyboard Shortcuts

· One min read

I've always been a fan of keyboard shortcuts, using them whenever possible. Today I accidentally pressed the Windows key and D at the same time — and suddenly found that my whole desktop was revealed. How did I not know about this? A quick search led me to a great page with another 8-10 shortcuts I didn't previously know. Now you too can be enlightened about the many uses of the Windows key.

Passing Objects Does Not Require 'ref'

· One min read

I'm willing to admit that I made a mistake, and I share this now for your reference (no pun intended): in C#, your basic data types (int, string, short, bool) are value-types. If you want to pass them to a method and have the original value updated, instead of a copy, then you must pass them with the ref or out keywords. But not so with reference-types (hence the name!), which includes classes.

One gray area: what to do with structs. That last link says: "when a struct is passed to a method, a copy of the struct is passed, but when a class instance is passed, a reference is passed." So there you have it. Definitely pays to know the differences between C# and C++!

Do not trust the generic List!

· 3 min read

Actually, that's a slightly misleading title. You should trust List<T>, but you should also know its limitations. Here is one of the dangers of launching into using new functionality without reading all of the documentation. I've been having trouble because a client application produces thousands of reports. These reports are supposed to be sorted in a particular manner. I've been sorting and sorting in SQL, and going not paying enough attention to test well. Results in production? Not sorted.

So naturally I started properly stepping through the application, inspecting results from SQL and in code. What do I find? That SQL is returning the proper sort order, but then the ordering is getting lost. Why is that?

Performance #7: An (unsafe) Dead End

· 2 min read

This article is part of the series An Exercise in Performance Tuning in C#.Net.

After a month-long hiatus — too much work, too fast and furious for posting — I'm back to the last posts in the series on real-world performance tuning. The point of these postings hasn't been to glorify my ability to tune a C# data processing application, but rather to share what I've learned in attempts to do so.

Where to next? Turns out my next steps were false starts, at least insofar as tuning is concerned. Still, there were some lessons (or should be) from these dead ends.

Ignoring SSIS Data Conversion Failures

· 2 min read

Problem

In SQL Server Integration Services (SSIS), you're trying to import from a data dump from another database system that has different data types from SQL Server. While the conversions look pretty straigh forward, you get failures of the type "The value could not be converted because of a potential loss of data.". But despite the mismatch data types, you can't see anything wrong.

AJAX RESPONSE Parsing Exception

· One min read

Problem

In newly AJAX-enabled .Net 2.0 page, buttons that redirect user to another page are suddenly throwing the following error:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from
the server could not be parsed. Common causes for this error are when the
response is modified by calls to Response.Write(), response filters, HttpModules,
or server trace is enabled. Details: Error parsing near
'<BODY><ASP_SMARTNAV_'.

Performance #6: Reading Directly Into the Parser

· 2 min read

This article is part of the series An Exercise in Performance Tuning in C#.Net.

As I look at the code I now have, I wonder if the fileLines variable is an unnecessary intermediate step. Can I rewrite so that stream.ReadLine() is passed directly into the parsing? If I do so, I'll be leaving the file open longer, but since no other application should be attempting to access the file, I'm okay with that. This means moving the open file command into MyClass.ProcessFile().

safnet logo