MessageBox blocking processing of DrawText
MessageBox blocking processing of DrawText
10 Oct 2022, 18:52
Good afternoon
Ive coded a cbot that identifies patterns on a chart and identifies them with letters. These letters are added to the chart using the DrawText command. Once A, B and C points appear on the chart I use a MessagBox to ask the user if they want to place an order. A and B appear on the chart when I expect them to. The DrawText for point C appears to be blocked by the call to (modal) MessageBox (even though the DrawText (C) fires before MessageBox). Once MessageBox is closed/acknowledged by the user the point C appears. I've created a dummy exhibiting the same behaviour below. Is there any way to force the system to process the DrawText before the MessageBox - as it would really help the user make the decision of whether to place the order if they could see all three points A, B & C? Or do I need to create a new thread (would stretch my programing skills, unless you can spell it out for me!).
Many thanks
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using System.Windows.Forms;
using System.Windows;
using System.Media;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.FullAccess)]
public class MyTest : Robot
{
protected override void OnStart()
{
var text = Chart.DrawText("Text1", "Hello World", Bars.OpenTimes.LastValue, Bars.HighPrices.LastValue, Color.Red);
MessageBox.Show("DrawText code not processed until after this MessageBox closes", "test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
firemyst
28 May 2023, 14:04
I see this thread hasn't been responded to, so thought I might say something in case it's still an issue? Or you'd like to revisit with a possible work around?
For starters, I would try this:
I haven't used it, but should allow for non-blocking operations because at the bottom of the page, it says, "While a message box is displayed, all other cBot/indicator events will be invoked normally."
Let us know how it works for you.
@firemyst