i have wpf application hosts wcf service. part of service ability close application client (running on same machine). use following code close in wcf service:
mainwindow form = mainwindow.currentinstance; form.mysynchronizationcontext.send(_ => form.closewindow(), null); my mainwindow setup static currentinstance variable can current window , call method added called closewindow via synchronizationcontext. works fine except takes long time close (about 10 seconds) lot longer if close app manually.
is there better way of doing more responsive?
update - @ moment closewindow function calls close() may few other bits eventually.
i have found solution problem don't understand why problem in first place should of been case.
the service declared following
[servicebehavior(usesynchronizationcontext = false)] it understanding statement, if service created within mainwindow class, still forced create it's own thread rather being run on ui thread. turns out doesn't seem case. have since moved host creation outside mainwindow class before creation , close happens immediately. can assume (without digging deeper) usesynchronizationcontext = false isn't forcing service host not created on ui thread.
although solves problem, love know why setting service behaviour making no difference.
Comments
Post a Comment