The Big Programming Thread - Page 466
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
Nesserev
Belgium2760 Posts
| ||
|
LaNague
Germany9118 Posts
Messung = new Thread(messen); Messung.IsBackground = true; Messung.SetApartmentState(ApartmentState.STA); Messung.Start(); Messung.Join(); private void messen() { dialog = new Form1(); dialog.Show(); Application.Run(); } (just quick example) from my thread. (dont ask -.-) Is there a way to stop that thread and unload the form that runs in it when the parent thread in terminating? Its a test application that runs tests on hardware and i want to pop up insctructorial pictures in my form, i got thato work. Once they press a button, which raises some digital line in a device connected by USB, the window goes away. and the thread ends. This works now. But i also want the window to go away when someone aborts the test, which means the parent thread terminates. I thought the background property would do that for me. | ||
|
mahrgell
Germany3943 Posts
I have the following C++ code:
For a program-to-program communication (GTP - http://www.lysator.liu.se/~gunnar/gtp/) protocol I thought the above inputreader would be enough. In short all commands by the the other program (the controller) come in form of a full line, and gtp_process_command is able to process those properly. All responses from my program are full lines as well. When doing tests on a console, this also works fine... (the program discards faulty lines, properly responds to all commands given to it, etc) But when I connect my program to a controller, an the controller sends multiple commands at once, my program simply ignores the 2nd command. My guess is, that the second input line from the controller comes before my program is done processing the first line, and thus getline() somehow fails to catch the second input line... If it is this, how to fix this problem? If this can't be the case, and above code should under all circumstances catch all lines... well... then I at least know I have to search the bug elsewhere... PS: of course gtp_process_command always gives back true, except the quit command was called, which wasn't the case here | ||
|
Zocat
Germany2229 Posts
On April 12 2014 09:14 LaNague wrote: So, i spawn a new UI thread with + Show Spoiler + Messung = new Thread(messen); Messung.IsBackground = true; Messung.SetApartmentState(ApartmentState.STA); Messung.Start(); Messung.Join(); private void messen() { dialog = new Form1(); dialog.Show(); Application.Run(); } (just quick example) from my thread. (dont ask -.-) Is there a way to stop that thread and unload the form that runs in it when the parent thread in terminating? I haven't done a lot of stuff with Forms recently. Parent keeps a list of all spawned child threads? Then when parent closes (FormClosed, FormClosing, ...) you terminate them. Children subscribe to parent closing event. Delegates. You can look at Form.OwnedForms / Form.Owner properties. "When a form is owned by another form, it is closed or hidden with the owner form." (For some reason I didn't use that the last time I had a similar problem with Windows.) | ||
|
Mr. Wiggles
Canada5894 Posts
There's still something like 20 hours left in the qualifying round, so plenty of time to do a few problems and qualify. code.google.com/codejam/ | ||
|
billy5000
United States865 Posts
| ||
|
MaGariShun
Austria305 Posts
On April 12 2014 16:14 billy5000 wrote: I have a question regarding using copyrighted material. For example, I have an idea for an app and want to use a pokemon character. And the app will be free (if that changes anything). Would I be safe to do this? I'm not that familiar with US law, but I don't think that it's legal except when it falls under Fair Use. At least in the copyright I'm familiar with, the copyright holder holds all rights about use, reproduction and work integrity. So I guess it depends on how you use it in your app. If it falls under fair use, you should be safe | ||
|
Ethenielle
Norway1006 Posts
Maybe I can excuse myself as being a hobbyist.... I saw the solution fast, but no way I could code it in time. No way. | ||
|
japro
172 Posts
| ||
|
Ethenielle
Norway1006 Posts
| ||
|
norlock
Netherlands918 Posts
. I hopy some of you try it out. | ||
|
teamamerica
United States958 Posts
For the Google Code Jam, in the number 3 example (Minesweeper): I can't understand how come the input case 2 2 1 Is impossible. To my understanding of the problem, with a 2x2 grid and one mine, you'll automatically win if you don't click on the mine, right? Can't figure out what part of the problem I'm misunderstanding. Wait nm I'm dumb. | ||
|
Zocat
Germany2229 Posts
On April 12 2014 16:14 billy5000 wrote: I have a question regarding using copyrighted material. For example, I have an idea for an app and want to use a pokemon character. And the app will be free (if that changes anything). Would I be safe to do this? Short version: You should avoid such situations, so no. Long version: Normally you are not allowed to use it. But there is this thing called "Fair Use". These are some guidelines (non profit, educational, academic, news reporting, criticism, ...) in which you can use copyrighted materials. Sadly they're just guidelines and you have no idea if your product is under Fair Use until you're in a court case. Free isn't really relevant since the Fair Use clause is "Non Profit". What about ads i.e.? And even if it's completely non profit it might still not be Fair Use (only a court knows). And if it is for profit it might still be Fair Use . The thing is, basically no one will care about your app, and in the case of it being really popular you might suddenly have a court case. Are you willing to risk that? And if you really want to risk it you should probably talk to a lawyer in person, or at least ask in a forum which has lawyers frequenting | ||
|
Shield
Bulgaria4824 Posts
On April 12 2014 22:11 Zocat wrote: Short version: You should avoid such situations, so no. Long version: Normally you are not allowed to use it. But there is this thing called "Fair Use". These are some guidelines (non profit, educational, academic, news reporting, criticism, ...) in which you can use copyrighted materials. Sadly they're just guidelines and you have no idea if your product is under Fair Use until you're in a court case. Free isn't really relevant since the Fair Use clause is "Non Profit". What about ads i.e.? And even if it's completely non profit it might still not be Fair Use (only a court knows). And if it is for profit it might still be Fair Use . The thing is, basically no one will care about your app, and in the case of it being really popular you might suddenly have a court case. Are you willing to risk that? And if you really want to risk it you should probably talk to a lawyer in person, or at least ask in a forum which has lawyers frequenting It sounds very vague indeed from what I've read on wikipedia as well. It's just a never ending way to earn/lose some money depending on which side you're. I think the best case is to ask author(s). | ||
|
klo8
Austria1960 Posts
| ||
|
obesechicken13
United States10467 Posts
I was reading page 32 here and what I understand so far is that it uses abstractions. But I don't understand the diagram below page 32. If this can be explained with skype, I'll pm you my skype id. Also the examples they give for Interface segregation are kind of confusing. (Page 14). Can someone explain that too? Does that mean that the different client interfaces are for different users like how an educational website might have interface classes for a teacher, student, and administrator (assuming the server side language was object oriented)? http://en.wikipedia.org/wiki/SOLID_(object-oriented_design) In this source they say that it's better to have one responsibility per class. I can agree with this. But why don't they have one class for drawing shapes and one class for defining rectangles. Instead they have one class for drawing only rectangles and one class for defining a rectangle's geometry. Doesn't that mean they would be making a different drawer for every shape? After that I'll probably need some help with Cascading (Is this similar to cascading deletes for DB?) and Facade but I'll ask later after I've done more reading. Are there any good videos I need to watch about creational patterns, structural design patterns, or behavioral patterns? | ||
|
nunez
Norway4003 Posts
src so if you're apt in c++ this is a really nice documentation. | ||
|
obesechicken13
United States10467 Posts
On April 13 2014 04:30 nunez wrote: there's a whole chapter on it in modern c++ design by alexandrescu (chapter 9): src so if you're apt in c++ this is a really nice documentation. Thanks. This is helping! | ||
|
Nesserev
Belgium2760 Posts
| ||
|
Shield
Bulgaria4824 Posts
Also, to the guy asking about the Factory pattern, here is a more concrete pattern than that. It's called the Builder Pattern, further reading. It's good if you have a constructor with too many parameters or you do not want to make an excessive number of constructors. You also don't have to remember a specific order for values, so that's nice too. While the Factory pattern generates an object for you, the Builder pattern allows you to refine it. Just in case you would like to learn more. | ||
| ||
I saw the solution fast, but no way I could code it in time. No way.
. I hopy some of you try it out.