Archive
Archive for April, 2007
Allergies
2007/04/16
1 comment
Having myself allergic rhinitis and suffering in recent years, I’d like to share some interesting posts on MSN about allergies:
Cold or allergy Which is it
Allergy-Proof Your Home
Food Allergies – Topic Overview
Food allergies – Food labels list top 8 allergens
Allergic Reaction – Topic Overview
Allergic Rhinitis – Overview
Categories: Uncategorized
Health
start/kill processes with VB.net
2007/04/15
6 comments
a friend was just asking me over MSN messenger how to start and kill processes using VB.net, so here is some info on it:
* to start a process you can just do
Process.Start("test.exe")
or
Dim proc As New ProcessStartInfo()
proc.Filename = "test.exe"
Process.Start(proc)
see
* to kill a process you can do something like (haven’t tried it though):
Dim plist As Process() = Process.GetProcesses()
For Each p As Process in plist
Try
If p.MainModule.ModuleName.ToUpper() ="TEST.EXE" Then p.Kill()
Catch
‘seems listing modules for some processes fails, so better ignore any exceptions here
End Try
Next p
see
Categories: Uncategorized
VB.net
+=1, -=1 not atomic operations at VB.net
2007/04/06
1 comment
This is something that bit me sometime ago: seems +=1 and -=1 aren’t atomic operations at VB.net and other .NET languages (not sure for C++) although modern CPUs have INC and DEC instructions at least for integers (maybe IL – intermediate language [for .NET compilers' target "theoretical" machine spec] – doesn’t define such?)
You have to use the class System.Threading.Interlocked and specifically the Increment and Decrement methods it has (you can pass an integer ByRef to them for example to do say i+=1 and i-=1 in a thread-safe way). That class also has methods to Add/Subtract more than 1 (haven’t checked if it also support multiplications/divisions etc.)
Many thanks to the guy who tiped me about this at a Microsoft Hellas presentation some years ago in Athens, wouldn’t have spotted that class myself, although I was already skeptical whether +=1 and -=1 were atomic operations (thread-safe, fetch and update done in 1 step) in VB.net and other .NET languages or not and was querying about it some MS Hellas people (who didn’t know either – I even asked J# program manager sometime ago and they had to doublecheck to be totally sure it didn’t do it as atomic operation either)
I wonder about what C++ compiler does on .NET regarding this one, I though the ANSI C++ spec said += and -= are atomic, but I might be remembering wrong
Categories: Uncategorized
VB.net
web.config’s schema change at .NET2: node doesn’t define child node anymore
2007/04/06
Leave a comment
At an ASP.net project I was moving from ASP.net 1 to ASP.net 2, at "web.config" file of the web application I had to move <compilers> child node of <configuration>/<system.web>/<compilation> node to a new <configuration>/<system.codedom> node.
The former one has been deprected at .NET2 (although still supported and overriding the <system.codedom>’s <compilers> setting if existing) and the Web.config XML editor was compilaing that the schema didn’t define a <compilers> child for <configuration>/<system.web>/<compilation> node.
Categories: Uncategorized
ASP.net