[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Avoiding blocking the UI while running hook scripts?

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Sun, 20 Apr 2008 19:27:43 +0200

Roger Lipscombe wrote:
> I'm looking into changing the way that hook scripts run, so that they
> don't block the UI. The issue tracker hook script is the most obvious
> example of this problem. I'm planning on having a dialog box pop up
> while the hook is running. It would contain text, something like "Please
> wait while the Issue Tracker hook runs".
>
> It might contain a "Cancel" button, which wouldn't kill the script
> (that's relatively hard), but it would abort the wait, and would return
> to the calling dialog as if the script failed. I'll have to think a
> little bit about how the background thread would be "garbage-collected"
> later -- we don't want TortoiseProc instances hanging around because the
> hook script is still running somewhere.
>
> (My model is the "Wait"/"Switch To"/"Cancel" dialog that you see when an
> OLE server is blocking).
>
> I'm thinking that it might work something like the attached (if you
> don't see any attached, let me know and I'll upload it somewhere). The
> interesting bits are in CModalStateDlg::OnBnClickedButton1() and
> CWaitForAsyncOperationDialog.
>
> This pattern generally works pretty well. I've used it in the past.
>
> Where I'm a little unsure is where to attach this to TortoiseProc. I
> could implement it in CCommitDlg::OnBnClickedBugtextbutton, or I could
> put it in CHooks::RunScript. That might require that RunScript be passed
> an hWnd to parent to. Currently, CHooks doesn't have much in the way of
> UI knowledge, and I'm reluctant to change that.
>
> Thoughts or comments?

I tried your demo project. Seems to work. But: closing the 'please wait'
dialog and then closing the main dialog leads to a crash because the
thread executing the 'script' is still running and of course isn't shut
down correctly.

You may now see why I never liked the idea of running scripts on a
thread or why I refuse to implement something that contacts the
repository or any server in the commit dialog.

Maybe registering a window message which the script can send back to the
commit dialog with info once its finished could help. Such messages can
be sent even by other processes, so it would be possible to start the
script as a different process - that way the commit dialog doesn't have
to care about a thread still running.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net

Received on 2008-04-20 19:28:08 CEST

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.