I have a remote service and an, object (singleton). When I call the singleton class from UI thread and remote service I get 2 objects. Can anyone help me?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
If you have a remote service then you have 2 completely separate processes. Each process has its own virtual machine. Therefore, your singleton class is instantiated once in each process.
If you really need a single then think about whether you really need a remote service. If you can implement your remote service as a local service then that will solve your problem.
If, on the other hand, you really need a single instance that is shared across the 2 separate processes, then you will need to instantiate the singleton only in the remote services process and access it via remote calls from the UI process.