Friday, August 01, 2003 - Posts

Delete not working ?!

Hey, has anyone noticed that the delete is not working for links and link categories in the new blog engine !! I am not sure whether everyone is experiencing this but it is not surely behaving the way it should for me. When i click on delete link, it does a postback but then nothing is being rendered .. I end up getting a blank screen and the link is still present ! hmm .. the first bug i've noticed till now.. And hey what happened to the images that were present in my General images previously ?? Does anyone have a clue ?

Ensuring Single process instance.

The following code demonstrates how to detect if there is an instance of your application already running. If detected, it will bring that application to the foreground, and then terminating the current application. This is useful in instances where you want to ensure that only one instance of your application is running.

<code>

using System;

using System.Diagnostics;

using System.Runtime.InteropServices;

class AppMain

{

[DllImport("user32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

[DllImport("user32.dll")] private static extern bool IsIconic(IntPtr hWnd);

private const int SW_HIDE = 0;

private const int SW_SHOWNORMAL = 1;

private const int SW_SHOWMINIMIZED = 2;

private const int SW_SHOWMAXIMIZED = 3;

private const int SW_SHOWNOACTIVATE = 4;

private const int SW_RESTORE = 9;

private const int SW_SHOWDEFAULT = 10;

static void Main()

{

// get the name of our process

string proc=Process.GetCurrentProcess().ProcessName;

// get the list of all processes by that name

Process[] processes=Process.GetProcessesByName(proc);

// if there is more than one process...

if (processes.Length > 1)

{

// get our process

Process p = Process.GetCurrentProcess();

int n=0;

if (processes[0].Id==p.Id)        n=1;  // Assuming only two instances of this process is presnt right now.

IntPtr hWnd=processes[n].MainWindowHandle;

// if iconic, we need to restore the window

if (IsIconic(hWnd)) {

ShowWindowAsync(hWnd, SW_RESTORE);

}

// bring it to the foreground

SetForegroundWindow(hWnd);

// exit our process

return;

}

// ... continue with your application initialization here.

}

}

</code>

I know what you are thinking .. Can't this be done using Mutex ?! Yup it can surely be done ! In fact it is easier to do it using Mutex class for this kind of a requirement. But then when i was trying some of the classes in System.Diagnostics namespace, i saw a particular snippet which does a similar thing to get the job done. And this is what i ended up with .. kewl !

Link interface 2.

Was a pretty dry day today till i did something useful .. I was searching for some good FileSplitter tool but then couldn't find a good one .. I have a file as big as 1 GB and i want to split it into chunks of 50 MB. But all the software's available for some reason bomb ! So i sat down to write a utility in c# to do precisely this .. Wow ! Now it feels good .. Can get to do some more coding for some more time.. Here are a bunch of links which i stumbled upon today ..

      1) Has anyone checked out the new blog site. It looks really cool ! I wonder how these people keep coming up with ui's like these .. But it seems a bit heavy and slow though !

      2) Old news but Donny mack has started the SqlJunkies blog site ! Wow !

      3) Codeproject has one good article about Fuzzy Logic implementation in .NET

      4) A friend of mine forwarded this link on the 5 patterns of extraordinary careers .. This is really good !

      5) In case you haven't checked it out, Finalbuilder is a tool to automate the .NET build process.. There are lots of new features that have been recently added !

      6) End Road for SMTP ?? Check out CNet News article ..

[Now Playing: Serenity - GodSmack]