Results 1 to 6 of 6
-
12th Jul 2010, 11:33 AM #1OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.com[C#] Difference with Invoke and Threading
Im just wondering, is there any benefits when it comes to Invoke or Threading.
and what's the difference:
PHP Code:
namespace Test
{
publuc class MyBox : Form()
{
public delgate SomeDelegate();
public void MyBox()
{
InitializeComponant();
SomeLibrary.OnFinished += new SomeDelegate(Method);
}
public void Method()
{
if(InvokeRequired)
{
new SomeDelegate(Method);
return;
}
//Access Here :/
}
}
}
litewarez Reviewed by litewarez on . [C#] Difference with Invoke and Threading Im just wondering, is there any benefits when it comes to Invoke or Threading. and what's the difference: namespace Test { publuc class MyBox : Form() { Rating: 5Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
12th Jul 2010, 11:50 AM #2Respected Developer
The Control.Invoke() method and Thread object are completely different so they can't have benefits over each other.
And what's the difference between what?
Why would there be some downside? Invoking is something that is required for doing cross thread calls.
-
12th Jul 2010, 01:32 PM #3OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.comI mean, When you use Control.Invoke, Is that Invoking a method on another Thread, or is that creating a new thread and then invoking the method.
Also, By doing new Thread(new Action(() => SomeClass,new object[] {this});.. Does that create a new thread and runs the object within that thread, and then to use that class i would have to use a Invoke?
Sorry ive just learnt that Invoking stops plenty of errors, and wanted to understand it a little more.
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
12th Jul 2010, 08:33 PM #4Respected Developer
The Action object is just a delegate. See this is why I keep advising people to read a book, because it answers most of these type of questions.
Read these:
- delegates http://www.aspfree.com/c/a/C-Sharp/C...tes-Explained/
- Invoke http://weblogs.asp.net/justin_rogers/pages/126345.aspx
They should clarify it a bit.
-
13th Jul 2010, 04:04 PM #5ლ(ಠ益ಠლ)Website's:
extremecoderz.comYou need to understand threading. If a thread is trying to access an object that it did not create, you need to invoke that object.
Example:
Main Thread: The initial thread used to create the program.
- Draws a textBox called TextBox1
- Draws a button called button1
Thread2 - self-created Thread.
- Tries to access TextBox1.
- Is returned an error "cannot access object thread did not create".
- Solution: Invoke the object.
This is a common example of useage for invoking objects whilst using threading.
-
13th Jul 2010, 04:53 PM #6OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.comYea looks like i was off the mark with separating Threads and Invoking
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Difference between VPS-RDP
By zoug100 in forum Hosting DiscussionReplies: 7Last Post: 30th Sep 2011, 12:40 PM -
difference?
By raghuram in forum Hosting DiscussionReplies: 2Last Post: 8th Aug 2010, 04:10 PM -
[c#] Multi-Threading and keeping the GUI useable.
By jayfella in forum Web Development AreaReplies: 0Last Post: 18th Jun 2010, 12:07 AM -
[PHP] Threading Class
By SplitIce in forum Tutorials and GuidesReplies: 8Last Post: 1st Oct 2009, 01:24 AM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...