Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
11 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Vishal_ARC · Jul 31, 2015 at 09:09 AM · coroutinefreezestartcoroutineweb services

Coroutine freeze other animation & UI part on service request

Hello,

When I do request for service call that time my coroutine freeze my game until response not come.... How can i do service request in unity coroutine or i used threading for that...plz help me

 IEnumerator ServiceCall()     {
     ChannelFactory<IService> factory_1 = null;
             IService channel_1 = null;
             string resultstr = "";
             try {
                 WSHttpBinding binding = new WSHttpBinding ();
                 EndpointAddress address = new EndpointAddress ("https://192.168.0.1/Service/Service.svc");
                 binding.Security.Mode = SecurityMode.Transport;
                 
                 factory_1 = new ChannelFactory<IService> (binding, address);
                 factory_1.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
                 channel_1 = factory_1.CreateChannel ();    
                 resultstr = channel_1.GetData(10);
                         yield return new WaitForSeconds (5);
                 Debug.Log(resultstr);

             } catch (Exception e) {
                 Debug.Log (e.Message);
             } 
                    yeild return break;
 }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Scribe · Jul 31, 2015 at 01:16 PM 0
Share

this page may be helpful

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Dave-Carlile · Jul 31, 2015 at 12:53 PM

I don't really know much about WCF, but my guess would be that the GetData call is a synchronous call so it waits until the data is available before it returns. Coroutines are a form of cooperative multitasking, so if the coroutine doesn't run quickly between yield statements, everything freezes.

You should be able to call an asynchronous method with WCF, so the call returns immediately, then the coroutine can loop and poll with yields inside the loop. Or use a callback or something, but that should give you something to google for.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vishal_ARC · Aug 01, 2015 at 11:12 AM 0
Share

yes your right, but how can i do that...

avatar image Dave-Carlile · Aug 01, 2015 at 12:16 PM 0
Share

I was going to point to $$anonymous$$icrosoft's async example, but I'm not 100% sure that will work in the version of $$anonymous$$ono used by Unity. It's worth giving it a shot though.

Otherwise you might need to use threading, or use Unity's WWW class to grab the data. There are JSON serializers that can then turn it into a class for you.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

My Coroutine is freezing my game? (no loops, serverSocket.Connect) 1 Answer

StartCoroutine important for using yield? 1 Answer

A loop FOR waits for a coroutine to end 1 Answer

Coroutine called in different instances 2 Answers

Why doesnt my coroutine ever end? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges