Monthly Archives: October 2010

Detaching Far Manager from long-running process on Windows 7

Occasionally I launch a program from Far Manager that takes very long to complete. Normally you can use Ctrl+Alt+Tab to “detach” Far from a running process. Technical note #27 explains this well:

If a long-running process (for example, archiving) was run in a FAR console, and for some reasons this very instance of FAR is needed (an editor in the background) or it is undesirable to run a new instance ofFAR, pressing this key combination will create a new console for FAR where it will continue running as if the process has already ended, and the process will continue working in the old console.

Unfortunately this doesn’t work on Windows 7. Instead of detaching you get Windows task switcher:

Windows 7 task switcher

Interestingly the switcher is in “sticky” mode. It doesn’t disappear when you release keys. You can use arrow keys to select a window.

The fix is easy:

  1. Start regedit, open HKCU\Software\far2\System key.
  2. Create ConsoleDetachKey string value, set it to some keyboard shortcut. I use CtrlAltX.
  3. Restart Far Manager

To test it try executing this command from Far:

ping -t

Press Ctrl+Alt+X to get back to Far without stopping pings.

Converting .Net DateTime to JavaScript Date

JavaScript Date constructor accepts number of milliseconds since Unix epoch (1 January 1970 00:00:00 UTC). Here’s C# extension method that converts .Net DateTime object to JavaScript date:

public static class DateTimeJavaScript
   private static readonly long DatetimeMinTimeTicks =
      (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).Ticks;

   public static long ToJavaScriptMilliseconds(this DateTime dt)
      return (long)((dt.ToUniversalTime().Ticks - DatetimeMinTimeTicks) / 10000);


var dt = new Date(<%= DateTime.Today.ToJavaScriptMilliseconds() %>);


Java System.currentTimeMillis() equivalent in C#