Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: RealmConfiguration not shared #3109

Closed
ghost opened this issue Nov 23, 2022 · 4 comments
Closed

[Bug]: RealmConfiguration not shared #3109

ghost opened this issue Nov 23, 2022 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 23, 2022

What happened?

realms are cool.

There is something strange about this test.

I've noticed a peculiar phenomenon where RealmConfiguration cannot be shared.
Remember to share RealmConfiguration after creating it in UI thread.
If you take out the RealmConfiguration from the thread and use it
A thread conflict error occurs.

I'd like to share my code, but unfortunately I can't because I'm testing it without using the reuse method.

Repro steps

realms are cool.

There is something strange about this test.

I've noticed a peculiar phenomenon where RealmConfiguration cannot be shared.
Remember to share RealmConfiguration after creating it in UI thread.
If you take out the RealmConfiguration from the thread and use it
A thread conflict error occurs.

I'd like to share my code, but unfortunately I can't because I'm testing it without using the reuse method.

Version

latest

What SDK flavour are you using?

Local Database only

What type of application is this?

WPF

Client OS and version

Windows 10 Pro 19044.2251

Code snippets

No response

Stacktrace of the exception/crash you're getting

No response

Relevant log output

No response

@papafe
Copy link
Contributor

papafe commented Nov 23, 2022

Hi @sansamit, I just wanted to confirm I have understood the situation.

You created a RealmConfiguration on the main thread and opened a realm with it. Then you used the same object to open a realm on another thread but you got an exception. Is this correct?
Also, what kind of exception/error did you get?

@ghost
Copy link
Author

ghost commented Nov 24, 2022

...
RealmConfiguration _config;

public void Main() {
    _config = new RealmConfiguration("...");
   using Realm realm = Realm.GetInstance(_config);

   Task.Run(() => {
       using Realm realm2 = Realm.GetInstance(_config);
       Test test = realm2.All<Test>().Where((_) => _.id == "abc");

       Console.WriteLine(test.Value);         <========== realm incorrect thread.!!!
   });
}

@papafe
Copy link
Contributor

papafe commented Nov 25, 2022

Thanks for the code, we'll investigate

@papafe
Copy link
Contributor

papafe commented Jun 25, 2024

I did not manage to reproduce this with the latest version of the SDK, so I am closing it for now. Feel free to reopen it if this is still an issue for you

@papafe papafe closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants