Click here to Skip to main content
15,918,193 members

Comments by Phillip Coiner (Top 4 by date)

Phillip Coiner 9-Feb-11 18:23pm View    
Hi SA
Sorry for the misplaced post to you I did mean to post to Marcus instead of you.
The reason tried the invoke/threading thing was that many of the posts to forms I found using a Google search listed threading as a cause of the exception.
I could not understand how threading was the cause, I said this in my original post.
I am sorry I included anything about threading, you are correct it only distracts from the real problem.
I currently move the data to and from the serial port object using delegates……...I’m a little fuzzy on the whole concept but I was able to get it to work.

I understand why Markus would recommend to move the serial port object out of my UI form, but it is working fine when it is implemented as a single form.
When my application was a single form it seemed logical to put it in the form.
I only explained the application so that you/Marcus could understand how much work it would be to completely redesign the architecture of my program to solve a problem, that should not be a problem …….…in theory (at least in my inexperienced mind).
I very much want to be able to know why this is happening.
I seems to me there a ought to be a way to figure out what exactly is going wrong.
I tried stepping into the function but the event is raised as soon as I try to step into the code.
Even if the solution it fixes my problem I agree it might be better to redesign the architecture but I would very much to understand the root cause of the problem.
What if I change the architecture and the problem remains? (this is unlikely as I created an empty form and deleted it with no problems)
I don’t understand why it is wrong/generates bugs to create and destroy forms?
Why are forms different than any other objects?
I create all kinds of other objects and destroy them as needed.
What is special about forms?
I create a string object and delete it, then the next time I need it I create another string and delete it.
From a theoretical stand point I don’t understand the difference between a form and other objects.
Thank you again for your help and patience.
I apologize for being difficult/abusive, it was certainly not my intent, I just want to discover the root cause of my original problem before I move on to redesigning my program.
Phillip Coiner 9-Feb-11 16:55pm View    
Hi Marcus
The serial port class is a different class.
I instantiate a serial port object on my form and configure it with dialog box which is also a separate class but I don’t see this as a particularly flawed from an architecture standpoint ……….…well except for the not working twice part :o)

The form has a status box to show the state of the serial port open/closed baud rate parity stop start bits and a connect/disconnect button.
It seems my forms would end up being just as complex having to pass all the connections and port status to each one instead of each one containing their own instance of these objects plus if I did all this I still would want to create and delete forms as needed.
The serial port configuration could be done in one spot but I liked having it right there to show the user what the state of things are at any given moment.

This app will be used to configure and control a RF device.
One form is a nothing but a terminal emulator, the other form has buttons so that instead of typing commands at the terminal it sends / and retrieves packets from the device , the other form……..not started yet would be a front panel emulator with controls that simulate the buttons on the device…which would be subset of the command sending form with different graphics.
Another form would generate RSA keys to lock/unlock features of the device………I have this working as a command line application.
All forms could use the serial port from one location but I hate to start ripping stuff out that is working just fine as an individual form because I can’t create and destroy an object more than once.
I can't believe/am astonished that creating and deleting windows forms is considered/is a bug generating process???

Isn’t object reuse considered the reason to have all this C# stuff in the first place?
I still would like to be able to figure out what the heck is causing the trouble.. …….even if I have to rip everything out and move it around to accommodate the API.
Thanks again to everyone for their suggestions and help……….even if it hasn’t fixed anything yet it is good to be able to talk to someone about it.
Phillip Coiner 9-Feb-11 13:43pm View    
Hi SA
In the form I instantiate serial port object.
I want to have other forms that use the serial port so I think I want/need to close the form and make a new one that has a serial port perform other functions.
I am unsettled by the thought of leaving forms hanging around consuming resources when I'm not using them also....thanks for the suggestion maybe I'll think about redesigning the architecture but I can't see why my current approach shouldn't work.
Phillip Coiner 9-Feb-11 13:38pm View    
Hi John
I had to change
EventHandler(cmdForm_Disposed)
to
EventHandler(mydForm_Disposed) in order to get it to compile
but I still get the exception thrown on Close();
I tried F11 to step into Close() on the debugger but I get the exception as soon as I do.