HELP ME WITH cycle WHILE. IT don`t work in cAlgo

Created at 15 Jul 2014, 14:43
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MI

mistica87

Joined 15.07.2014

HELP ME WITH cycle WHILE. IT don`t work in cAlgo
15 Jul 2014, 14:43


void process()
        {
            while (true)
            {
                try
                {                   
                  Print("Test");                   
                } catch (System.Exception e)
                {
                    Print(e.Message);
                }
                Thread.Sleep(20);
            }
        }

        protected override void OnStart()
        {          
            ThreadStart ts = delegate { process(); };
            Thread th = new Thread(ts);
            th.Start();
        }

When I run this code. CTrader not cope, RAM is overloaded, growing and CTrader freezes. Help solve the problem.

I need cycle with 20 miliseconds interval. I can`t use timer, becouse now it only in seconds.


@mistica87
Replies

Invalid
16 Jul 2014, 09:27

RE:

Probably memory is growing because you add message to log every 20ms. 

I've answered you about timer in another thread.

 

mistica87 said:

void process()
        {
            while (true)
            {
                try
                {                   
                  Print("Test");                   
                } catch (System.Exception e)
                {
                    Print(e.Message);
                }
                Thread.Sleep(20);
            }
        }

        protected override void OnStart()
        {          
            ThreadStart ts = delegate { process(); };
            Thread th = new Thread(ts);
            th.Start();
        }

When I run this code. CTrader not cope, RAM is overloaded, growing and CTrader freezes. Help solve the problem.

I need cycle with 20 miliseconds interval. I can`t use timer, becouse now it only in seconds.

 


@Invalid

Spotware
16 Jul 2014, 12:33

Please avoid accessing API objects and functions from separate threads. cAlgo.API is not thread safe.


@Spotware