Hello you All;

I have a recursive function which makes the UI freeze in my program.I would like to put this function in another thread however, because there are a lot of control connected with main form, whenever I attempt to run it VC# gives me a cross thread error which is I am dealing with right now.

Also the function uses a structure which is on another class.

I have tried to call my radiobuttons using the code I wrote below, but I am not sure this is the correct way to do this..

Please help me out.. Thanks in advance
delegate void SetButtonCallback(RadioButton WhichOne, bool button);
private void SetButton(RadioButton WhichOne, bool button)
if (WhichOne.InvokeRequired)
SetButtonCallback d = new SetButtonCallback(SetButton);
this.BeginInvoke(d, new object[] { WhichOne, button });
WhichOne.Checked = button;