I'm fairly new to programming, so sorry if I mess some of the words up, also I guess this question is probably really stupid.
Anyways, I'm trying to control a C# browser window from a different thread.
The program has 2 windows. A console and the Form with the browser window.
namespace CodeSnippet
{
public partial class browserwindow : Form
{
public browserwindow()
{
InitializeComponent();
//for the browser form to open, the console HAS to run in a seperate thread
Thread ConsoleThread = new Thread(new ThreadStart(TheConsole));
ConsoleThread.Start();
}
public static void TheConsole()
{
while(true)
{
//read the input
string rawinput = Console.ReadLine();
string input = rawinput.ToLower();
//look for commands
if(input == "website")
{
Console.WriteLine("Waiting...");
string website = Console.ReadLine();
//TheBrowser is the name of the browser window
TheBrowser.Navigate(website);
Console.WriteLine("done!");
}
}
}
The "TheBrowser.Navigate" does not work in this piece of code. However, if I remove the "static" on "TheConsole()" the code works perfectly fine.
Now my question is: Is it 'okay' to remove the static from the function?