C# and Mutexes (Muteces?)

14 11 2006

I’m new to getting multi-threading working in C#, so I’m looking for some help with Mutexes.

I have code that looks like the following:

Mutex MyMutex = new Mutex();

Then later in parts that I want to make sure work at separate times:

void Part1()
{//Do Stuff}
void Part2()
//Do other stuff
//that must be not at the same
//time as Part1

Is this the correct way to make sure that these two methods (which get called via various triggers) don’t run while the other is running?  Comments and help appreciated.

2006-11-15 Update…  Figured out the problem.

Can anyone help with C# and WMI??? I’m STUCK!

19 07 2006

I am trying to create a tool for new user creation so that our Help Desks can create users, home directories, the shares, and add them to

It was all good until I got to creating shares on the servers (some are DC’s)  I can’t find ANY WAY to get around the following (in C#):

System.Management.ManagementClass mc =
      new System.Management.ManagementClass(“\\\\” + oHomeServer.Text.Trim() +
      “\\root\\cimv2”, “Win32_Share”, null);
System.Management.ManagementBaseObject inParams = mc.GetMethodParameters(“Create”);

I get “Access Denied” exception when I run this as a NON-Admin user in the HelpDesk Group.  I have given ALL rights to the WMI services to the
“HelpDesk Group” on server which I am creating the share.  It won’t let me 😦

When I log into a PC as that user, and run through computer management/attach to server and then go through “Create a new share”, it all works great… Directory is created, share is created etc.  This would indicate to me that the user has rights to do this, but that the code being called by the tool is different than the code that _I_ am calling 😦
What rights do I need for the HelpDesk Group on what aspects of what object for this to work?   What code should I call instead? I have
brick shaped dent in my forehead from this problem, and the balding patch is growing larger from pulling all my hair out!!!!

So, all you WMI and security gurus out there… help please.

Heck, even if you don’t know the answer, but know someone who MIGHT know the answer, I’d appreciate it… either leave a comment or use the Contact Link.


Not at your work PC, and need a compiler…. Problem solved

12 06 2006

Interesting little site purports to allow you to type in your source code and it will compile and send you the executable.  C#, VB.Net, Fortran and the venerable “C”

It even does syntax highlighting.

Might be nice if you need a quick one off hack, but certainly limited by things like need for config files etc?

Ajax and Atlas – Not just cleaning detergent and a map book!

20 03 2006

Microsoft has released a new Community Technology Preview of Atlas for March  2006. Atlas is a framework for building “Rich Client Applications” in ASP.Net 2.0 using AJAX.  This is cool.  This could be a big plus for .Net if Atlas REALLY does make it easy to create classes in Javascript for consuming webservices asynchronously.  I’m going to pull it down later tonight to see what’s possible.  I’m excited!

Someone’s been spying on our tech support group again

26 01 2006

C. Enrique Ortiz has a funny one that someone passed on to him:

Top 10 replies by developers when their programs don’t work:

10. ‘That’s weird…’
9. ‘It’s never done that before.’
8. ‘It worked yesterday.’
7. ‘You must have the wrong version.’
6. ‘It works, but it hasn’t been tested.’
5. ‘Somebody must have changed my code.’
4. ‘Did you check for a virus?’
3. ‘Where were you when the program blew up?’
2. ‘Why do you want to do it that way?’

and finally …

1. ‘I thought I fixed that.’

What a Unique Thought – Coding with Security in Mind

21 05 2004

Don Box has posted a link to a very interesting little online security book for .NET development.

Wouldn’t it be nice if Microsoft EVERYONE coded with security AND functionality in mind?

%d bloggers like this: