|
All code that draws to the UI in a particular window must be in a single thread. Even MDI child windows must be drawn by the same thread as the parent (a restriction I would think wouldn't be necessary if the system were could force thread synchronization when, and only when, a child window changes dimension). If you want to create the appearance of having things done by different threads, you need to have a UI thread that avoids doing anything that will take much time, and then have other threads supply information to the UI thread. As an example (not the best approach, but a workable one) you could allocate three bitmaps for one of your tabs. At any given moment, one may be in use by the UI thread (copying data from it to the screen), one may be 'ready' for the UI thread to grab at its convenience, and one will be in use by the helper thread to draw the next screen. When the helper thread finishes drawing a bitmap, it tells the UI thread to display it (using BeginInvoke if there isn't already a request pending). If there was a bitmap pending for display but the UI thread hasn't started showing it yet, the helper thread can take it back (since the UI should show the newer bitmap). Otherwise the helper thread can reclaim the previous bitmap the UI thread displayed (since the UI thread is done with it).
I'm not sure of the best way to handle the thread synchronization, but an easy way would be to recognize that there are twelve possible bitmap states (the drawing tread can hold any of three bitmaps and the UI thread one of the remaining two, and the remaining bitmap may or may not have data that should be displayed). The state can easily be held in an integer, and Threading.Interlocked.CompareExchange used to handle state updates in thread-safe fashion.
This approach would not be the best for fast and frequent display updates (since the whole tab would have to be redrawn for every update) but it would be a simple way to provide essentially total separation of the two threads.
|
|
|
|
|
Hi,
What I need to be able to do is to set the top and bottom of the range displayed on the graph to 32,500 and -32,500 and plot values within this range, even if they are of the order +100 to -1000 say. I have tried Scale.Max and Scale.MaxGrace but neither of these appear to FIX the top and bottom values. Does anyone know if there is a way to do that?
|
|
|
|
|
I am trying to solve a problem of selecting the best students for admission to different programmes in a school, based on their weight scores but I get a brain jam because i think the logic is quite complex. the rules are that :
1. each student is allowed to have 6 choices of programmes
2. their weights are calculated for each programme
3. each programme has a predetermined number of students for in-take
4. a student qualifies for a programme in the order of the choices made as long as he ranks within the number of students required for the programme for example (a) if a student qualifies for 3 programmes of his choice, he is given the one closest to his first choice, and (b)if a student qualifies for his last choice he is admitted
Please help!
Gideon
|
|
|
|
|
Sounds straightforward to me. Calculate the weights for all students who request a specific program, and choose the top xx, where xx is the number allowed.
Is this homework, or paid work ? If it's homework, you should talk to the teacher. If it's paid work, and you have no idea how to do it, you really should offer a refund.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanx Graus so far but what you are saying is the first impression. remember that students have up to six choices and a student has to be admitted for only one programme and so your suggestion suffers from the result having students short-listed for more than one programme.
i am proposing to develope this program for my research at school. it is not paid work. I can do the code for calculating the weight
Christian Graus wrote: Sounds straightforward to me. Calculate the weights for all students who request a specific program, and choose the top xx, where xx is the number allowed.
Is this homework, or paid work ? If it's homework, you should talk to the teacher. If it's paid work, and you have no idea how to do it, you really should offer a refund.
s and all. the problem is this logic am inquiring about
|
|
|
|
|
Gideon W. Wananda wrote: remember that students have up to six choices and a student has to be admitted for only one programme
Add a List<> to your application. Dump the students ID into that list once he/she enrolls in a "programme".
You can use the students' preferred programme whilst there is room
I are troll
|
|
|
|
|
Before I go crazy on this I was wondering if somebody could point me in the right direction
I was trying to use a structure to store "datasets"
Anyway: Creating / populating the structure seems straight forward
Public Structure Test_Structure
Public Name As String
Public MapTo As String
Public Description As String
'......
'....
End Structure
Dim TEST(10) as Test_Structure
Test(0).Name = "FirstName"
Test(1).Name= "SecondName
But How do I now search / get the index for the Dataset containing the .name "FirstName"
Should I use a Hashtable to store the index ????
Thanks
georg
|
|
|
|
|
You would use foreach to iterate over your array and check each item for the value you want.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Well if that's the "only" way, a Hashtable will be a lot faster
I just can not belive there is not another way of indexing a Structure .
One would think that indexing / searching is probabaly one of the most required tasks to be performe with a structure - But I might be wrong
Georg
|
|
|
|
|
Well a structure doesn't automatically build indexes into all it's data, imagine how wasteful that would be if it did that even when not required. Yes, a hashtable would be faster.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
First of all, you should not use a structure for this, you should use a class. A structure should not be larger than 16 bytes, and you break this if you have more than four string references. Also structures are tricker than classes to implement correctly.
If you want a fast lookup for a field you can create a Dictionary with the field as key and the object as value.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I have written code that captures the image of windows. It works fine but when I try to capture "Program Manager" (the desktop), it captures ok, but the whole screen goes black and using alt tab to redraw some of the screen and then taskman to quit my program is the only way to get it all fixed. Why does this happen when tryng to capture Program Manager?
|
|
|
|
|
|
No. The actual window of the desktop is named Program Manager. For some reason snapshotting it specifically causes the problem above.
Screenshot:
(thats what it looks like once I try to snapshot program manager. The snapshot it takes does look like the desktop correctly though.
http://i258.photobucket.com/albums/hh243/omnicoder/err.jpg[^]
|
|
|
|
|
Hi, I am looking for help on an app that alows me to select fields from access to populate a form (could be multipage form) with subset of recordes and export the form into word or start with a word doc it does not matter
please contact me asap, I am willing topay for help.
Thank You,
Simon sybaco@gmail.com
simon
|
|
|
|
|
Sorry, unless you have a specific question about code YOU are writing, you've come to the wrong place. You may want to try RentACoder.com.
|
|
|
|
|
|
I need an image to match an exact size however the image that must match the size is always different. How can I add blank transparent space around an image to increase the size?
For example say I have 3 images. 520x200, 340x400 and 700x500 and they must all be 1280x768. How can I add blank space around the 3 images so they will all be 1280x768?
|
|
|
|
|
There are two possibilities. The first is that you don't need to add anything to the image. Depending on your requirements, you just do the math to center the image properly and draw it yourself. The second is that you create a bitmap object of the size required and, again, do the math to center the image and draw the image onto the new bitmap.
|
|
|
|
|
Thanks creating a blank stretchec bitmap from a blank transparent png and drawing on it worked. Thanks for the help!
|
|
|
|
|
Omnicoder wrote: creating a blank stretchec bitmap from a blank transparent png
Why would you do that? Just create a new empty bitmap...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I have a data input form (Name, address, phone, etc) (Form2) that is launched from the main page (Form1). I want to use the same form for both add and edit functions - is there a way i can do something like this:
["Add New User" button pressed on Form1]
Form2.Show()
(Form2 Loads...)
If.....then...
btnAddNewUser.Visible = True
btnEditUser.Visible = False
basically, for Form2 to "know" what button was pressed on Form1, and change the buttons that are visible on Form2 based on Form1 input. Global variables? Or is there a function that will automatically do this?
Thanks!
|
|
|
|
|
sarmedic wrote: basically, for Form2 to "know" what button was pressed on For
You have several options
sarmedic wrote: Global variables?
This will work, but is nasty as hell
sarmedic wrote: Or is there a function that will automatically do this?
No
The most obvious way to do this, is to pass a flag in to the constructor for your form, or if the same form is used over and over, then make it a property on the form. Why do you call Show and not Show Dialog ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I am new to VB express 2008 express edition. I am working through some materials and am trying to design the form and write the coding to the following problem and am struggling greatly. Can anyone do it and I will work back from it and see where I am going wrong. I have one day to complete it.
A manager of a canteen want to write a program to calculate how much each customer has to pay. Memebers of staff are to pay VAT on their purchases but pupils do not. If the customer is a member of staff then the program will calaculate the VAT and add it to their total cost.
VAT is calculated using the formula.
VAT=0.175 * total cost
Their are 3 inputs in the program.
1 how many items the customer wants to buy,2
2 the price of each item and
3 whether the customer is a pupil or a member of staff (P for pupils and S for staff)
Output must display the total cost of the purchases, the type os customer, the amount of VAT paid and the final cost.
I would be really grateful if you could help me.
Thank you
|
|
|
|
|
Oh dear, this really isn't a good first post for the Code Project forums. You shouldn't ask us to do your homework and you probably should have started it before now.
Can anyone do it and I will work back from it and see where I am going wrong.
It would be better if you let us see what you've done, if in fact you have done anything, and then we'll take it from there. Try to post specific questions with short code snippets that illustrate any problem you may be having.
Alan.
|
|
|
|