The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Archive for November 24th, 2016

Internet Archive Wayback machine – New Beta Release Allows Users to Keyword Search

Posted by jpluimers on 2016/11/24

I totally missed this because most of my WayBack activity is through the JavaScript buttons on my Chrome toolbar, so here it is:

A month ago, the WayBack machine introduced a new beta that allows for searching inside the archives.

Some links:

There actually seem to be two betas going on at the same time:

–jeroen

Posted in InternetArchive, Power User, WayBack machine | Leave a Comment »

Single Malt Fiber…

Posted by jpluimers on 2016/11/24

Via [WayBack] Office so, am Nebentisch: “Mumble, mumble, single mode, mumble, single mode fiber, mumble””Ich höre die Hälfte der Zeit Single Malt. – Kristian Köhntopp – Google+

While you’re waiting for the packet exchange anyway, enjoy 45 minutes of uninterrupted Lagavulin™ Single Malt Scotch Whisky-drinking bliss with Nick Offerman by the Yule Log Fireplace… and you don’t even need to exchange words… (thanks René Riech).

Or as a close friend would describe it: genitaal…

— more —

 

Posted in About, Fun, Personal | Leave a Comment »

The Delphi Vcl.Forms.TApplication.ActionUpdateDelay unit is … milliseconds

Posted by jpluimers on 2016/11/24

Don’t you love relevant documentation…

There is no unit defined for the Vcl.Forms.TApplication.ActionUpdateDelay – RAD Studio API Documentation.

It is used inside the TAppliation.Idle to fire the (undocumented) TApplication.DoActionIdle method. When the value is zero or less, then each Idle call will result in an DoActionIdle call in turn calling TCustomForm.UpdateActions for any visible form.

UpdateActions in turn will call (for the form itself, all the form’s menu items and all the form’s controls) the TControl.InitiateAction which – if there is an associated ActionLink – will call the TBasicActionLink.Update which in turn will call the TBasicAction.Suspended and TBasicAction.Update methods of which the latter will call the TBasicAction.OnUpdate event if it is assigned.

In theory, the OnUpdate method for each action can even be called multiple times (because multiple controls on visible forms can point to it), but the real culprit is that TApplication.Idle as it can be called from these places:

  • TApplication.DoApplicationIdle
  • TApplication.HandleMessage (in a loop from TApplication.Run)
  • TCustomActionMenuBar.ProcessMenuLoop (in a loop)
  • TCustomRibbon.DisplayKeyTips (in a loop)

The last three (especially HandleMessage) can be disastrous as they can be called a lot (for instance when moving the mouse), and more often than not, the OnUpdate event handlers aren’t exactly CPU friendly.

A while ago I bumped into an application where the OnUpdate event handler for one action was called half a million time in under 5 minutes.

This clearly indicated a huge problem (besides using a full CPU core slowing down the application) as apparently something was broadcasting Windows Messages like crazy.

Investigating and Solving the message flood is on the back-log with a reasonably high priority, but the highest priority issue was fixing the high CPU usage in the first place.

Apparently more users suffer from this, as there is a Vcl.Forms.TApplication.ActionUpdateDelay property which TApplication.Idle uses to call the Windows API function SetTimer to rate-limit the TApplication.DoActionIdle call tree. Luckily SetTimer does have documentation on the unit of ActionUpdateDelay: it’s milliseconds.

I’ve set it to 10 as that updating the actions ~100 times a second is fast enough for this application.

–jeroen

via:

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Delphi: function IsRunningFromNetwork – via Lars Fosdal. I will need this one day

Posted by jpluimers on 2016/11/24

If I ever need it: function IsRunningFromNetwork that is based on WNetGetConnection.


function IsRunningFromNetwork(const ServerName:String = 'BetYouCantFindThisServer'): Boolean;
const
pMax = 2047;
var
dt: UINT;
volpath: Array[0..pMax] of Char;
sVol: String;
sz: Cardinal;
begin
Result := False;
dt := GetDriveType(PChar(ExtractFilePath(ParamStr(0))));
if dt = 4
then begin
GetVolumePathNameW(PChar(LowerCase(ParamStr(0))), volpath, pMax);
sVol := StrPas(volpath);
if not ((pos(LowerCase(ServerName), sVol) <> 0) or (pos('\\', sVol) = 1))
then begin
if pos(':', sVol) <> 0
then begin
sz := pMax;
if WNetGetConnection(pChar(Copy(sVol, 1, 2)), volPath, sz) = NO_ERROR
then Result := (pos(LowerCase(ServerName), LowerCase(StrPas(volPath))) <> 0) or (pos('\\', StrPas(volPath)) = 1);
end;
end
else Result := True;
end;
end;

Thanks Lars; I copied it to a gist for easier WordPress handling.

–jeroen

via:

Posted in Delphi, Development, Software Development | Leave a Comment »