Good morning, I have an application that in a given moment throws a Thread, inside that Thread it is called a user control where an image is put in a button inside the user control.
The user control has a list of Tuples composed of a TextBox and a Button, in order to know which Button is associated with each TextBox.
The problem I have when I try to search within that list of tuples to which button you have to put the image.
I put the code used:
The part where the Thread is created to run in the background:
Thread preparaPDF = new Thread(() => lanzaComprobacionPDFIndividual(idActual));
preparaPDF.IsBackground = true;
preparaPDF.Start();
Inside the PDDFindividualTraveler launches the user control visorPDF is called:
visorPDF.anadeFichero(listaIDs[idActual], ficG, true);
and the function where I get the error, is in anadeFichero
public void anadeFichero(string id, string ruta, bool bueno)
{
try
{
Button b = (Button)listaRelacionada.Find(x => (x.Item1 as TextBox).Text == id).Item2;
if (b != null)
{
b.Tag = ruta;
habilitaBoton hab = new habilitaBoton(enableBoton);
b.Invoke(hab, b, bueno);
}
}
catch (Exception ex)
{ }
}
In fact, I've put a try catch in case it throws an exception but does not throw anything, it stops there.
This error is very strange to me, since as it is seen in theRelated list, if there are values.
Then I put a screenshot of how it looks in debug.
Thanks for the help.