Using B125.
I use Windows MessageBox in some of my strategies. On running one yesterday I noticed that the box opened in the background, behind WealthLab. It *always* used to open in the foreground, on top of all windows.
Is this a Windows or WealthLab issue?
P.S. Some of my strategies use InputBox also, which is opening correctly in the foreground, as always.
I use Windows MessageBox in some of my strategies. On running one yesterday I noticed that the box opened in the background, behind WealthLab. It *always* used to open in the foreground, on top of all windows.
Is this a Windows or WealthLab issue?
P.S. Some of my strategies use InputBox also, which is opening correctly in the foreground, as always.
Rename
Strategies are executed in a separate thread, so if you want to use MessageBox in a Strategy you need to carefully consider this. Here's a pattern that shows the MessageBox on the UI thread, and suspends the execution of the Initialize method until after the user clicks OK.
CODE:
public override void Initialize(BarHistory bars) { bool canContinue = false; ThreadUtils.ThreadSafe(new Action(() => { MessageBox.Show("Box"); canContinue = true; })); while(!canContinue) { Thread.Sleep(100); } }
Working great... thanks!
---------------------
It's strange, though... I've used System.Windows.MessageBox.Show(Msg) for years w/o issue and then this happened... must've been some recent Windows Update.
---------------------
It's strange, though... I've used System.Windows.MessageBox.Show(Msg) for years w/o issue and then this happened... must've been some recent Windows Update.
Your Response
Post
Edit Post
Login is required