|
Hi, I hope my responses are received by you as in the spirit of appreciation for your curiosity and experimental attitude !
I think (if I understand what you are pursuing here) the broad question you are asking is:
"How can I have a WinForm based UI, like-a-TabControl, with each thing-like-a-TabPage within the like-a-TabControl hosting an ActiveX control which runs in its own thread."
An interesting question ! If you care to comment, I'd like to know what you envision as the practical functionality or benefit such an architecture would enable.
A few minor comments:
1. TopMost and TopLevel are not the same creature. TopMost[^] is used to guarantee that a Form ... not a Form within a Form ... stays, while shown, in the same z-order as other Forms in the same application with TopMost=true. And other windows of your application will not be allowed to visually appear between the main form and the form(s) with TopMost = true. This is useful for 'floating' tool palettes.
And, an alternative to 'TopMost' is to set the Form.Owner property[^] of a Form (which can only be another Form): that's useful for other types of interfaces in the 'kind-of-modal' domain. ... edit ... out of order comment moved ...
Another alternative out-of-the-box way of approaching your application you may wish to explore is to modify the Program.cs file so it does not launch a Form to begin the application, but calls some function (perhaps in a static class) that launches various Forms. This technique requires you to make sure that when all Forms you've launched are closed the Application is terminated, or you will have the App running 'forever' with no UI ... edit ... this comment moved here ... where it should have placed ... I like to call this the "down with the Tyrant Main Form" architecture
That's easily done by a trivial modification of each launched Forms 'FormClosing event to examine the count of open Forms in Application.OpenForms and do the right thing if you are closing the only-one-left-standing.
So, you have a 'vast palette' of Forms related properties, and possible relationships between Forms, to work with. And you ... are the artist.
Curiousity is good !
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
modified 25-Oct-11 23:30pm.
|
|
|
|
|
I miss spoke. I meant to say TopLevel, not TopMost.
OK, why is this important. This is a real time trading system where each tab contains a charting component (COM object) as well as a data feed ActiveX component handling 50+ pieces of information each second. The tab panel would typically show 4 to 6 charts. Each tab represent a market GOOG, YHOO, GM for example. From a GUI stand point, the use of tabbed pages allows one to cleanly switch easily between market symbols. There is quite a bit of analytically work to be done on the data. Given I have eight threads on my PC, I want to effective run each market in its own thread as it were. Off course I realize I'm share my processes with other system and application threads.
|
|
|
|
|
I find this a fascinating scenario, and will look forward with interest to, hopefully, hearing comments on best practices for this kind of architecture from folks on this forum like Hans Dietrich, Bob Janova, Luc Patyn, Pete O'Hanlon, and Eddie Vuiggen, and many others, who are constant sources of challenge and education for this old out-to-pasture once-upon-a-time PostScript guru dabbling in .NET
To the extent you find it useful, and care to share more information on how you are managing the threads ... I'd be curious. Is this a situation where processing is being explictly done using Parallel Extensions, or using a CPU with multi-cores ?
And, does each thread have its own independent connection to some data source (internet ? dedicated something ?) in real-time, so you literally have eight 'live feeds' all coming in simultaneously ... not multi-plexed into packets ?
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
I certainly appreciate your interest. Regarding CPU processor, I have 4 cores and 8 threads. Intel i7 930. You are spot on the last point, each thread does have its own independent data feed.
One final note. It seems that the childforms that are created via the code I posted are referenced to the desktop. This means that the mouse pointer is offset from the chilform by the distance from the childform top left corner and the top left corner of the desktop. When you click on a childform and move the mouse it will jump. I've spent a number of hours trying to fix this problem to no avail. However, if you make the childform full docked and set it as a MDI container, you now can create childforms within this overlay form that behave correctly. Of course visually you might what to remove the top bar on forms 2 and 3, with 4 being the childform. Moreover, using the earlier tricks you can have each childform run in the thread of the parent or a new thread.
Bottom line, what we have here is really a tabControl were each tab page runs in its own thread.
|
|
|
|
|
OK, while I can see what you've done here, I would have to question why you've done it. Is it that the ActiveX components are interfering with each other being STA? Are they responsible for processing the feed? Before we can offer further advice, we really need to know why you are having to work around your controls.
|
|
|
|
|
I'm flattered to be included in that list
|
|
|
|
|
I still don't think you want the forms in separate threads. Do the market processing in separate threads, sure – since they're independent and of roughly equal processing intensity, that is a natural division of effort that makes a lot of sense to make use of the cores. But the heavy processing is in the analytics (having done a bit of trading code myself I know that the complexity of those is limited by your imagination or the ability to run within the tick speed, and speed is usually a bigger constraint) – you should be able to keep the UI all in one thread (avoiding the side effects I mentioned in my last post of a multithreaded UI) and notify it from multiple threads.
Because the data will be being touched all the time you might need to queue updates and take a non-volatile UI thread copy of the data, or use Invoke (not BeginInvoke) so that the processing is stalled while the UI update completes. This rather depends on your analytics and how much of the data you want to be visible on the UI; if the UI is just displaying the output of the analytics you shouldn't need to be too clever with update synchronisation, but if you want to see numbers (or particularly tables; DataGridViews don't take kindly to their binding source being updated) you will.
|
|
|
|
|
I think some of the responses here to what appears to be an identical design scenario to yours may be relevant:[^].
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
Some weeks ago I sort help achieving the following functionality:
"Dynamically create a tab-page, place a form on it running in it own thread"
I need to do this because I want each of these forms to run like a separate application within an integrated framework. The application is very time critical, handling multiple, but independent streams of data.
I thought at the time that I had found a way to do this, however, as it turned out my solution did not work reliably - do not use the code I posted previously. Sometimes it worked, other times it didn't, and in the most extreme crashed my PC. You think its working and then for no good reason it crashes; hence, why we are told the the GUI must run in the main thread. I tried many different approaches to no avail.
However, I had a stroke of luck and discovered that the order of operation is perhaps the key to cracking this nut, possibly avoiding a race condition that creates the instability. What I now have as a prototype that appears completely robust and shamelessly breaks all the rules.
The prototype application needs to be interdependently tested. That person must be expert at threaded applications. Also, this would have to be done under an NDA, they could not publish the method. I now that there are some highly talented people that participate in this forum. Contact me if interested.
|
|
|
|
|
Since I am new to working with linq in a C# 2010 .net application, I have the following question to ask:
In some new code that I need to write, I need to insert a new row in org1 table where the identity (key) column is called org1_id. I also need to insert a row in org2 table that has org1_id column as foreign key (that is associated with org1 table.
How would you accomplish this task?
The following is what i have so far:
[^]org = new Organization();
PopulateOrganization(org);--puts data in all the appropriate columns
orgModuleDataContext.Organizations.InsertOnSubmit(org); [^]
|
|
|
|
|
It seems your question is related more to Entity Framework than Linq specifically.
This is about performance but there are examples of foreign key relationships with EF.
Entity Framework Performance[^]
No comment
|
|
|
|
|
Hi,
What is the best way to convert a point string to a point object ?
Point Pt1 = new Point(10, 20);
string strPt = Pt1.ToString();
Point Pt2 = ? (use strPt to convert back to Point object)
Thx.
|
|
|
|
|
paper67 wrote: What is the best way to convert a point string to a point object ?
Using the appropriate TypeConverter[^]
Bastard Programmer from Hell
|
|
|
|
|
First new class of the week!
|
|
|
|
|
No, they won't be covering classes or instantiation for a while yet
|
|
|
|
|
|
Interestingly, I tried that but it fails, as the ouput of Point.ToString() is not parsable by the converter.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I'm not surprised. The .ToString method shows the contents of the object, it doesn't convert it to it's string-representation. I'd expect one would have to go from object->string and vice versa over the TypeConverter .
Bastard Programmer from Hell
|
|
|
|
|
If you have control over both parts of the operation, i.e. this is for persisting some data you own to disk/network/etc, you should use the TypeConverter:
Point pt1 = new Point(10, 20);
string strPt = TypeDescriptor.GetConverter(pt1).ConvertToString(pt1);
Point pt2 = TypeDescriptor.GetConverter(typeof(Point)).ConvertFromString(strPt);
If you don't have control over the string format, you will have to write a parser. It's pretty simple (clean off the brackets, split on ',', verify two parts, aand parse both halves as int).
|
|
|
|
|
If you have control over both ends, why use strings at all?
|
|
|
|
|
As an intermediate format without having to resort to serialization
Bastard Programmer from Hell
|
|
|
|
|
|
True, that's an option too
You can store every class by simply looping it's public properties, and to store the contents as a string. (Storing both ints in a string is the same thing) That would mean that you have to pay attention to the format, and match up the encode/decode functions.
The TypeConverter is a somewhat "safer" way of converting your class, because it adheres to a fixed format for that type in a human-readable form. It's not only used for locations, but also for colors and the like. This would be my recommendation.
A third option would be serialization. That'd be a bit overkill in this particular situation, but it remains an option.
Bastard Programmer from Hell
|
|
|
|
|
Well I was just going to store the ints and ints, but yea it really depends on where the data is supposed to go..
|
|
|
|
|
Eddy Vluggen wrote: You can store every class by simply looping it's public properties, and to store the contents as a string. Just curious: you mean by using Reflection ?
And, if I may ask, why would serialization be "over-kill" in this scenario ... assuming this question is not a one-off, but has broader implications.
And, how about using Mehdi Gholam's zippy implementation of JSON on steroids here on CP ? Over-kill ?
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|