Fix callback to be registered just once

Thanks to Rob for reporting this issue

from ldtp import *

import threading
callbackRunning = threading.Event()
callbackRunning.clear()
callbackState = threading.Event()
callbackState.clear()

def cb():
    callbackState.set()
    print 'cb'
    waittillguiexist('Windows Help and Support')
    click('Windows Help and Support', 'btnClose')
    callbackState.clear()
    callbackRunning.set()
    print 'callbackend'

onwindowcreate('Windows Help and Support', cb)

activatewindow('Calculator'); generatekeyevent('<F1>')
wait(1)

if callbackState.isSet():
    print 'Waiting for callback to complete'
    callbackRunning.wait()
    print 'callbackset'

QA Notes:
Testing Done: http://ldtp.myfastforum.org/viewtopic.php?p=202#202
Documentation Notes:
Bug Number:
Reviewed by:
Approved by:
Mailto: