Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:49:16+00:00 2026-05-15T13:49:16+00:00

This is a question about best practices i guess but it applies directly to

  • 0

This is a question about best practices i guess but it applies directly to my current MT project.

I’m using WCF services to communicate with the server.

To do this i do the following:

services.MethodToCall(params);

and the asynch:

services.OnMethodToCallCompleted += delegate{
    //do stuff and ting
};

This can lead to issues if you’re not careful in that variables defined within the scope of the asynch callback can sometimes be cleaned up by the gc and this can cause crashes.

So – I am making it a practice to declare these outside of the scope of the callback unless I am 100% sure they are not needed.

Now – when doing stuff and ting implies changing the ui – i wrap it all in an InvokeOnMainThread call. I guess wrapping everything in this would slow the main thread down and rubbish the point of having multi threads.

Even though I’m being careful about all this i am still getting crashes and I have no idea why!

I am certain it has something to do with threads, scope and all that.

Now – the only thing I can think of outside of updating the UI that may need to happen inside of InvokeOnMainThread is that I have a singleton ‘Database’ class. This is based on the version 5 code from this thread http://www.yoda.arachsys.com/csharp/singleton.html

So now if the service method returns data that needs to be added/updated to the Database class -I also wrap this inside an InvokeOnMainThread call.

Still getting random crashes.

So… My question is this:

I am new to thick client dev – I’m coming from a web dev perspective where we don’t need to worry about threads so much 🙂

Aside from what I have mentioned -are there any other things I should be aware of?

Is the above stuff correct? Or am i miss-understanding something?

Cheers

w://

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:49:16+00:00Added an answer on May 15, 2026 at 1:49 pm

    FYI, we got over this hump by keeping a reference to the original controller when the app finishes launching (in our case a navigation controller). The issue we were facing was that the GC was clearing up the controllers because it thought it was un-necessary because they were declared within the scope of the method.

    I hope this answer helps someone else in the future.

    Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is a subjective question, but I'm always curious about best-practices in
This may be a question about convention, best practices and/or personal preferences: So I'm
I guess this is more of a general best practices question. WordPress recommends including
Colleagues, Preamble. My question is more about best practices. I know one workaround. This
This is more a question about best practices. I have a view with many
this is mostly a theoritical question about the best practices. I'm currently programming a
I have this question about best practices in following examples: interface Request; interface Service
This is a question more about best practices/design patterns than regexps. In short I
This is kind of a question about best practices. I have a PL/SQL block
This is a question about sass best practices. Lets say I have a _colors.scss

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.