Hello, all. I'm working on a new project now that I can talk about.

I've been hired to fix code that performs frame capture and magnetic sensor telemetry.

I haven't worked in C# before this, but it is similar enough to the work I was doing when I last frequented these boards that I can get by.

However, I've got a real doozy of a problem.

In order to try to restore the company-provided frame capture code (Birdman) into the much more functional GUI that was written by another temp. employee... Who also claimed that Birdman was 'not going about it the right way', and reworked the frame capture into something functional, but unable to perform as well.
For example, Birdman can capture at 15 frames/second on all of the systems that it ran on, but Ubird (the modified version) does not. Ubird also cannot capture 30 frames/second on any system.

There's a lot of strange stuff going on in my attempts to get Ubird operational, but this is the strangest.

It makes initialization seemingly have a 'goto line number' command, causing repeated calls of 'new' until a stack overflow exception occurs.

During the initialization process, the following code appears.

private (some.data.type) setup=new frmSetup();
//Other initializations here
public frmSetup()
{
InitializeComponent();
}

When frmSetup is called and I track it through debug, it only gets as far as the frmSetup() function, but then does not enter the function. It returns to the 'new frmSetup()' and tries to enter the function again.

If I move 'new frmSetup()' down the list of initializations, it behaves the same way, but the control returns to where 'new frmSetup()' originally resided, and runs through all the initializations between its original and new location, then loops until the exception is called.

I have NO clue what is causing this. Has anyone else encountered this behavior, and if so, how can I fix it?

lol ok so the for is creating a new instance of itself in the InitializeComponent(); method which is an endless loop.

the way to fix this is simple, you just make the new object from outside of the class. i dont see the idea of making a new form of its self inside of inself.

soo here is a little sample code

//this creates a new Form2 from Form1
		private void Form1_Load(object sender, System.EventArgs e)
		{
			//create new Form2
			Form2 myNewForm = new Form2();
			//Show It
			myNewForm.Show();
			//Preforms Method2 on Form2(optional)
			myNewForm.Method2();
			//closes Form2
			myNewForm.Close();
		}

so basicaly what im saying is that "private (some.data.type) setup=new frmSetup();" should not be in frmSetup. it should be in a different class.

that is unless this is the startup form for the application then in that case you just put "Application.Run(new Form1());" in your main() function

I believe that it is called outside frmSetup. I don't have the code in front of me (I can talk about what I'm doing, but I can't bring it home), but Thanks for the response, and I'll check into that tomorrow.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.