How do I resize Listview columns in a threadsafe manner - C#
<p>I have a query to a database on a seperate thread and on the return I invoke a threadsafe call. But an exception is created - what am I doing wrong?</p>

<p>Note I also populate the list view but have left it out for clarity</p>

<pre><code> private void ThreadSafeListView()
    {


        if (this.listView1.InvokeRequired)
        {
            try
            {
                ThreadSafe Operation d = new ThreadSafeOperation(ThreadSafeListView);
                this.Invoke(d );
            }
            catch { }
        }
        else
        {


            listView1.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView1.Columns[1].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView1.Columns[2].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView1.Columns[3].AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
            listView1.Columns[4].AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);


        }
    }
</code></pre>

<p>Exception Details=
InvalidOperationException :
"Cross-thread operation not valid: Control 'listView1' accessed from a thread other than the thread it was created on." </p>
