IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-10-24 20:19:38
Channels: 41
Logged Lines: 6230436
Size: 1825.67 MB
Powered by
Channel Info
Network: freenodeChannel: #csharp |
Search in www.irclog.org
Log from #csharp at freenode 2006-07-11
Pages: < Prev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Next >
[01:52]<jdvgdjgcgd>user will not see updates
[01:52]<ymuggjt0ot>and handles the events ?
[01:52]<jdvgdjgcgd>no
[01:52]<jdvgdjgcgd>never block the ui thread
[01:52]<jdvgdjgcgd>never use while loop polling
[01:52]<ymuggjt0ot>oh ok.. i didnt know if it did a break sort of thing or what :P
[01:53]<ymuggjt0ot>you can use that just dont do it in the UI thread
[01:53]<jdvgdjgcgd>no, dont do it ever
[01:53]<jdvgdjgcgd>while loop polling, no no
[01:53]<jdvgdjgcgd>while( true ) { /test condition, then sleep / } <-- bad
[01:53]<ymuggjt0ot>are you talking about like while (1) { foo = recv(); } ?
[01:53]<jdvgdjgcgd>no, recv() is a blocking call
[01:53]<azyfm>he has a blocking call
[01:54]<ymuggjt0ot>oh you used the word polling.. linux "poll" function can block :)
[01:54]<jdvgdjgcgd>polling like, "wait right here until [n] is done"
[01:54]<ymuggjt0ot>what you were looking for is the word "busy waiting"
[01:54]<jdvgdjgcgd>yeah, busy waiting
[01:55]<jdvgdjgcgd>avoid that pattern at all costs, even on a seperate thread
[01:55]<ymuggjt0ot>yes busy waiting is bad unless you are writing embedded code or the wait time is less than a context switch
[01:55]<azyfm>well, never say never, spinlocks use busy waiting
[01:55]<jdvgdjgcgd>especially never on the ui thread
[01:55]<jdvgdjgcgd>doing that forces you to gobble up cpu cycles on idle tasks
[01:55]<d0`><Jivemonkey> while( true ) { /test condition, then sleep / } <-- bad
[01:55]<jdvgdjgcgd>wake up, check for some crap, go to sleep, context switch
[01:55]<d0`>why is this bad?
[01:56]<ymuggjt0ot>spinlocks are usually only used for kernel code anyways
[01:56]<jdvgdjgcgd>its bad because you gobble up cpu cycles without actually doing work
[01:56]<ymuggjt0ot>also you dont get the response right way if you oversleep it
[01:56]<azyfm>I've seen managed synchronization code that spins
[01:56]<d0`>Jivemonkey how do I improve it then? What should I do?
[01:56]<jdvgdjgcgd>use an asychronous call, then block against its waithandle
[01:56]<ymuggjt0ot>call a function that blocks until there is a response
[01:56]<azyfm>usually they yield the thread if they don't get the lock very quickly, though
[01:57]<ymuggjt0ot>Arild: yep.. it makes sense when you expect to obtain a lock in less time than a process switch
[01:57]<d0`>Jivemonkey: Sorry, I don't understand
[01:57]<jdvgdjgcgd>read up on waithandles
[01:57]<jdvgdjgcgd>manualresetevents
[01:57]<azyfm>or a thread switch, even
[01:57]<ymuggjt0ot>read up on BeginInvoke
[01:57]<d0`>Jivemonkey- Why wont I do another thread that handles that
[01:57]<ymuggjt0ot>thats probably the easiest way to doit
[01:58]<jdvgdjgcgd>because your thread is gobbling up cpu cycles it doesnt deserve
[01:58]<d0`>Why wont I place that in a function that I place in a thread
[01:58]<ymuggjt0ot>also some methods block by default i.e. Socket.Read()
[01:58]<jdvgdjgcgd>oh, because async methods give you the thread and thread management free
[01:58]<pz2>anyone know off hand if mono support accessing an MSSQL server out of the box?
[01:58]<azyfm>I think it does
[01:59]<ymuggjt0ot>also if your threads are user space then its stealing cycles from other threads, even worse if you have no sleep code in there cause then other threads never get executed
[01:59]<jdvgdjgcgd>thread starvation
[01:59]<d0`>I am confused
[01:59]<d0`>I am being told many stuff (
[02:00]<jdvgdjgcgd>we're all saying the same thing
[02:00]<ymuggjt0ot>it all boils down to this......... use a method that will block until it receives a response
[02:00]<vyzusdjvnnv>w00t
[02:00]<jdvgdjgcgd>but never block on the UI thread
[02:00]<d0`>That loop ALWAYS sends signals to the device so I need it to loop alaways
[02:00]<pz2>can someone recommend a good mono tutorial for someone who already has programming skills?
[02:00]<jdvgdjgcgd>i dont even know what method you're talking about, heh
[02:01]<pz2>mono/C# that is
[02:01]<d0`>http://pastebin.ca/84456
[02:01]<d0`>I am doing this method: http://pastebin.ca/84456
[02:01]<ymuggjt0ot>frb: http://www.gotmono.com/docs/index.html
[02:01]<ymuggjt0ot>thats actually a table of contents of tutorials and not an API
[02:01]<pz2>good enough for me
[02:02]<ymuggjt0ot>http://www.go-mono.com/docs/ <<< API
[02:02]<ymuggjt0ot>Confusing use of URLs, eh?
[02:02]<pz2>we have 2 completely different sites, differentiated only by tld
[02:02]<pz2>one is .com the other .org
[02:02]<ymuggjt0ot>yes but they are both sort of official
[02:02]<ymuggjt0ot>and the URLs look similar
[02:03]<ymuggjt0ot>i always get them confused
[02:03]<zgzzcygnv>isnt mono trademarked or something?
[02:03]<ymuggjt0ot>m0`: hdWaitForCompletion should be blocking until it gets a response back
[02:03]<ymuggjt0ot>the only time you would use a non-blocking version is if your code does something useful incase there is nothing available yet
[02:04]<d0`>I cannot alter hdWaitForCompletion
[02:05]<d0`>And I need that loop
[02:05]<ymuggjt0ot>how does it work, does it block, does it use a file descriptor... etc
[02:05]<d0`>what do you mean, how does it work?
[02:05]<ymuggjt0ot>thats exactly what I mean, what does it do and how does it do it..
[02:05]<d0`>It sends parameters to the device
[02:06]<ymuggjt0ot>yeah but does it send them instantly or what
[02:06]<d0`>yes
[02:06]<d0`>Instantly, realtime
[02:06]<ymuggjt0ot>well then its ok to do what you're doing
[02:06]<d0`>but The whole application is freezing
[02:06]<ymuggjt0ot>except I would maybe loop up to X times
[02:06]<ymuggjt0ot>thats because you're doing it in the UI thread
[02:06]<d0`>so I shoiuld make it a new thread?
[02:07]<ymuggjt0ot>if it takes you more than a few microseconds to send the HD command you should be doing something else
[02:07]<ymuggjt0ot>yes just asynchronously execute it
[02:08]<d0`>how do I asynchronously execute it?
[02:08]<d0`>Should I addit to a therad?
[02:08]<ymuggjt0ot>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpovrasynchronousprogrammingoverview.asp
[02:08]<d0`>thank you
[02:08]<d0`>ahh more delegates
[02:08]<gdrn_frmd>Hi!
[02:08]<d0`>Why can't I just assign the tread for that function?
[02:09]<ymuggjt0ot>you can but using begininvoke and asynchronous calls are supposed to be cleaner
[02:09]<ymuggjt0ot>it does the thread managing for you
[02:10]<d0`>but I have to place that function in a new class







