Задача на параллельную задачу.invoke()
при выполнении первого цикла (i = 0)
System.InvalidOperationException: 'Invalid cross-thread operation: the 'boxframe' control was accessed from a different thread than the one from which the creation was performed.'
Что я уже пробовал:
private void CreaThumbs(string path) { ..... Action[] actions = new Action[3]; actions[0] = () => CreaBox(i); actions[1] = () => CreaImage(i, path, FileImg); actions[2] = () => CreaButton(i); for (i = 0; i < elementi; i++) { ........... (Parallel.Invoke(actions); .......... } private void CreaBox(int i) { boxCornice[i] = new Label(); .... } private void CreaImmage(int i, string path, string NameFile) { //create PictureBox pictBox[i] = new PictureBox(); pictBox[i].Parent = boxCornice[i]; //controllo associato ........ } private void CreaButton(int i) { btnRotateSx[i] = new PictureBox(); btnRotateSx[i].Parent = boxCornice[i]; .... btnRotateDx[i] = new PictureBox(); btnRotateDx[i].Parent = boxCornice[i]; .... } ... }
F-ES Sitecore
Google the error message for solutions (вам нужно использовать "Invoke") - это очень часто задаваемый вопрос.