• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Threading problem using AsyncSocket
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threading problem using AsyncSocket


  • Subject: Threading problem using AsyncSocket
  • From: "Matthew Youney" <email@hidden>
  • Date: Thu, 14 Aug 2008 14:49:12 -0400
  • Importance: Normal

Hello list,
This is my first attempt at threading with Cocoa, and I am having difficulty
with my classes that use AsyncSocket.  I am using DetachNewThreadSelector:
to detach my ‘worker’ thread, and I am instantiating my class that uses
AsyncSocket from within this thread.  The problem is that the AsyncSocket
delegates are never called.  This class works just fine from the main
thread.

- (IBAction)RunTestButtonPressed:(id)sender
{
            [NSThread detachNewThreadSelector: @selector(threadFunction:)
toTarget: self withObject: recipe];
}


- (void) threadFunction:(BeverageRecipe*)recipe
{
ClassContainingAsyncSocket* foo;
int i=0;

            while (stuffTodo)
            {
NSAutoreleasePool* autoReleasePool=[[NSAutoreleasePool alloc]init];

            foo=[[ ClassContainingAsyncSocket alloc]init];

            i=[foo readRegister:0];  //none of the AsyncSocket delegates
‘fire!’

            [autoReleasePool release];


do more stuff….
            }

}


Does anyone have any idea what I am missing?  Something fundamentally wrong?
Thanks in advance for any and all assistance.

Matt
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: @try @catch
  • Next by Date: Animation layer conflict w/ IKImageBrowserView
  • Previous by thread: Re: Why does Core Data retain an object when one of that object's attributes is changed?
  • Next by thread: RE: Threading problem using AsyncSocket
  • Index(es):
    • Date
    • Thread