To prevent a cross-threading exception I have the following static method:
public static void SetText(System.Windows.Forms.Form form, System.Windows.Forms.Control ctrl, string text)
{
if (ctrl.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
form.Invoke(d, new object[] { form, ctrl, text });
}
else
{
ctrl.Text = text;
}
}
coming from this answer
It works solid but I was wondering: The form object contains all kinds of controls etc but passing the object around does not cost extra RAM or such as it seems.
How come?
Isn't there any difference in usage of RAM if;
- I'd execute this method in the form class itself
or
- I'd pass the entire form object to this method in a different class?
EDIT
I was confused due to an article I had read persueing not to pass the Windows.Form object (can't find the article) so I automatically linked this with possible high usage of RAM passing objects.