.NET Scheduled Timer - Cross-thread operation not valid : <p>I'm using the Schedule timer  <a href="https://www.codeproject.com/Articles/6507/NET-Scheduled-Timer?fid=36218&amp;df=90&amp;mpp=25&amp;sort=Position&amp;spc=Relaxed&amp;prof=True&amp;view=Normal&amp;fr=1#xx0xx" rel="nofollow noreferrer">www.codeproject.com</a></p>

<p>But, when working with the listview I received the error below:</p>

<p><strong>Cross-thread operation not valid: Control 'lsViewIm' accessed from a thread other than the thread it was created on.</strong></p>

<p>Here's my code:
This is for my button to execute the timer:</p>

<pre><code>delegate void TickHandler(string Profile);
private void btnStart_Click(object sender, EventArgs e)
{
    Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);  

    if(ConfigurationManager.AppSettings.AllKeys.Contains("Stock-Enable"))
    {
        if (config.AppSettings.Settings["Stock-Enable"].Value.ToString() == "Y")
        {
            main.oWriteText(lsViewIm, "Reading... " + DateTime.Now.ToString(), Color.Black, false, "logs"); 

            IScheduledItem Item = GetSchedStock();
            _AlarmTimer.Stop();
            _AlarmTimer.ClearJobs();
            _AlarmTimer.AddJob(Item, new TickHandler(updateStocks), "Woo1");
            _AlarmTimer.Start();
        }
    }
}

private ScheduleTimer _AlarmTimer = new ScheduleTimer();
private IScheduledItem GetSchedStock()
{
    return new ScheduledTime("ByMinute", "1"); 
}
</code></pre>

<p>This code will show details to ListView:</p>

<pre><code>public void oWriteText(ListView lsView, string txt, Color? oColor = null, Boolean isStored = false, string oFile = "logs")
{
    ListViewItem addItem = lsView.Items.Add(txt);
    lsView.EnsureVisible(lsView.Items.Count - 1);
    addItem.SubItems[0].ForeColor = oColor ?? Color.Black;
    lsView.Refresh(); 
}
</code></pre>

<p>And this is my method, and will put here the rest of the code here.</p>

<pre><code>public void updateStocks(string Profile)
{
    oWriteText(lsViewIm, DateTime.Now.ToString(), Color.Black, false, "logs");
    return;
}
</code></pre>
