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.68 MB
Powered by
Channel Info
Network: freenodeChannel: #csharp |
Search in www.irclog.org
Log from #csharp at freenode 2006-07-17
[23:11]<vufvuzn>So I need to update a WinForms UI but I'm receiving notification from a thread other than the UI event processing thread. Is there some call I can use to pass a delegate/event/lthing to be invokd in the UI thread?
[23:12]<vufvuzn>similar to Java's SwingUtilities : invokeLater & invokeAndWait
[23:12]<sugsxdgnlrmd>Hello
[23:13]<txnjzd>vulture: try Control.Invoke
[23:13]<vufvuzn>Theory: thanks, I'll take a look
[23:15]<vufvuzn>any logical way to choose which Control to Invoke on? or just pick any?
[23:16]<txnjzd>vulture: the one you are trying to call methods on traditionally
[23:16]<txnjzd>or the form containing it
[23:17]<vufvuzn>sure, thanks again
[23:17]<lnvnzxu>vulture: normally i write a method responsible for interacting with a given control by first checking the InvokeRequired property, and then recursing on itself via Control.Invoke, if required
[23:17]<lnvnzxu>which keeps me from working which thread i'm using it from
[23:18]<lnvnzxu>working = worrying
[23:19]<lnvnzxu>(or, the real reason: keep other developers from worrying about it)
[23:20]<sugsxdgnlrmd>when running a windowsapplication by default a form is starting, how can i assign which item is started?
[23:21]<vufvuzn>peterhu: sure, sounds good
[23:22]<lnvnzxu>also read the notes for the InvokeRequired property, as it can return false in the case where no window handles exist yet
[23:23]<vufvuzn>in which case one is free to update because there can be no UI thread interaction? sure.
[23:24]<vufvuzn>now I'm just tyring to figure out this delegate stuff. Is this "Delegate" type somehow not compatible with the fancy new(er) "delegate(){}" kind of syntax?)
[23:24]<lnvnzxu>well, you just don't want to accidentally create the handle on the thread that doesn't own the control
[23:25]<lnvnzxu>vulture: unsure, what error are you receiving?
[23:27]<vufvuzn>might start with what I'm doing: c.Invoke(delegate() { ... }); - error is "type expected" then various other thingns
[23:27]<vufvuzn>excuse my somewhat slow connection
[23:27]<kjr>sup vulture, peterhu, Theory
[23:28]<vufvuzn>g'day kog
[23:29]<vufvuzn>(oh, and have I mentioned how hard it is to come up with new strong passwords & actually remember them - I tried about 20 times earlier today
[23:30]<sdnffdxdlld>i tend to rememeber a string of words and numbers then use them like an acronym and just rememeber where to put a symbol or 2
[23:30]<sdnffdxdlld>not truly secure but better than a phrase or word
[23:32]<kjr>vulture: I just finished memorizing my common 12 character alpha/num/symbol
[23:32]<vufvuzn>yeah, I working on similar ideas, but just the first few times is annoying - trying to remember which case I used where, how I invented the words, etc
[23:32]<sdnffdxdlld>aye
[23:33]<sugsxdgnlrmd>can anyone please refere to my question?
[23:33]<vufvuzn>so - any tips on that delegate stuff?
[23:33]<lnvnzxu>vulture: sorry back; you'll need a type cast there so that the compiler knows the type of the anonymous method to emit; something like c.Invoke((MethodInvoker) delegate() { ... });
[23:33]<kjr>SunShineLady: can you rephrase it to make more sense?
[23:33]<sdnffdxdlld>my friend used to use some strange rhyming scheme to do his it worked pretty well once you rememebered the rythem
[23:33]<kjr>SunShineLady: perhaps include some details
[23:34]<lnvnzxu>however, i'd use a non-anonymous method to simply call the method again, saves you from one more level of indirection
[23:34]<sugsxdgnlrmd>kig - I have a form and an MDI when is start the app the form pops up, i want the MDI
[23:34]<vufvuzn>peterhu: well it's just the last couple of lines of this method, but yeah - it's worth considering. I'll have a go
[23:35]<kjr>SunShineLady: I don't do MDI in C#, don't rightly know
[23:35]<sugsxdgnlrmd>sorry...
[23:36]<sdnffdxdlld>lol kig
[23:36]<lnvnzxu>erm, i mean simply: delegate void FooHandler(); void Foo() { if (c.InvokeRequired) { c.Invoke(new FooHandler(Foo)); return; } if (!c.IsHandleCreated) { /* doh! */ } ... }
[23:36]<sugsxdgnlrmd>Gog - I think its the same if I have 2 forms, I don't know how to switch item and assing whats starting with the app
[23:37]<sdnffdxdlld>SunShineLady ... forms are like any other object ... you access them via thier instance
[23:38]<lnvnzxu>hey kog
[23:38]<sdnffdxdlld>Form form = new Form();
[23:38]<lnvnzxu>(returning your greeting from before)
[23:38]<kjr>sup peterhu
[23:38]<sdnffdxdlld>access the form with form.property = something;
[23:38]<lnvnzxu>pretty busy today, need to get a fix in for a deadline on wednesday
[23:39]<sugsxdgnlrmd>sorry about the misspell its not on purpose
[23:39]<kjr>peterhu: right on... I'm doing some synchronizing our stores... it's real fun
[23:40]<kjr>just found out one of our queries has a 60 second runtime
[23:40]<lnvnzxu>well i've already done the fix, but it requires installer changes, so i'm less than motivated to get it done =)
[23:40]<lnvnzxu>i'm hoping that when the deadline is looming it will motivate me more
[23:42]<sugsxdgnlrmd>smellyhippy - I think you didn't understand me, I have form1 running when i start the app when i want MDI to show instead
[23:42]<sdnffdxdlld>right so have you looked at the app entry point?
[23:42]<sdnffdxdlld>are you using 1.1 or 2.0?
[23:43]<sugsxdgnlrmd>VS 2005 .NET2
[23:43]<mrvnm>is it possible to get a unique id for a given instantiation of an object? i'm looking for something similar to the pointer value in c.. as in 2 variables that reference the same object should be able to get the same id, but a different variable referencing a different object of the same type should return a different id
[23:43]<sdnffdxdlld>righty sso check out the Program.cs in the WinForms project
[23:44]<mrvnm>for example if i wanted to walk a graph and serialize the nodes but not re-serialize something i've already done
[23:45]<sdnffdxdlld>daved: you could just do if(!collection.contains(object))?
[23:45]<mrvnm>smellyhippy: not the approach i want to take.. i dont want to put everything in a giant collection
[23:45]<mrvnm>pretend it's a very large graph and i'm serializing to file
[23:45]<sdnffdxdlld>well how would you check using a unique id?
[23:45]<mrvnm>a large collection of id's
[23:46]<mrvnm>which is much smaller than a collection of all of the objects
[23:46]<sdnffdxdlld>no its not
[23:46]<sugsxdgnlrmd>smellyhippy - thanks
[23:46]<sdnffdxdlld>a collection of object references is small
[23:46]<sdnffdxdlld>np SunShineLady
[23:46]<sdnffdxdlld>you dont stored the objects ... just thier references
[23:46]<mrvnm>also i want to be able to index the objects based on this id so i can store their internal references properly when serializing
[23:47]<mrvnm>are you suggesting an alternate solution because it's not possible?
[23:48]<sdnffdxdlld>but why do you need the id?
[23:48]<sdnffdxdlld>the reference is the id
[23:48]<mrvnm>ok, say i was serializing
[23:48]<sdnffdxdlld>yer
[23:48]<mrvnm>A contains B, B contains C and C contains A
[23:48]<mrvnm>the only way i can see to properly serialize that would be to call the objects "A" "B" and "C" in an index, and then reference the id during serialization
[23:49]<sdnffdxdlld>are they your own objects?
[23:49]<sdnffdxdlld>or 3rd party?
[23:49]<mrvnm>any objects
[23:49]<mrvnm>ok, i appreciate the attempt, but i'm really just looking for the answer to the question i asked first
[23:50]<sdnffdxdlld>well you can look into hashcode
[23:50]<sdnffdxdlld>that might provide what you want
[23:52]<mrvnm>ah GetHashCode() it is, thanks
[23:52]<sdnffdxdlld>np
[23:53]<sdnffdxdlld>now i've gotten what you mean with the complex referencing i can see the issue ... i've never trtied it with serialization so I've never realised the need there







