Sergey_New Well-Known Member Licensed User Longtime User Sep 12, 2023 #1 How can you deinitialize a custom class without closing the activity in which it was initialized?
Solution William Lancee Sep 12, 2023 If you declare the instance again without initialization, it is not initialized. But it is unusual to need to do this! B4X: Dim sl As SuperList sl.Initialize(Me, "") Log(sl.IsInitialized) 'True Dim sl As SuperList Log(sl.IsInitialized) 'False
If you declare the instance again without initialization, it is not initialized. But it is unusual to need to do this! B4X: Dim sl As SuperList sl.Initialize(Me, "") Log(sl.IsInitialized) 'True Dim sl As SuperList Log(sl.IsInitialized) 'False
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Sep 12, 2023 #2 Why do you need to de-intialise the class. Java garbage collector will clean it up as necessary. Upvote 0
Sergey_New Well-Known Member Licensed User Longtime User Sep 12, 2023 #3 Andrew (Digitwell) said: Java garbage collector will clean it up as necessary. Click to expand... The program cannot wait, it should continue executing the code. Upvote 0
Andrew (Digitwell) said: Java garbage collector will clean it up as necessary. Click to expand... The program cannot wait, it should continue executing the code.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Sep 12, 2023 #4 Sergey_New said: The program cannot wait, it should continue executing the code. Click to expand... ??? What do you mean? The garbage collector does not stop execution. Can you provide some example code? Upvote 0
Sergey_New said: The program cannot wait, it should continue executing the code. Click to expand... ??? What do you mean? The garbage collector does not stop execution. Can you provide some example code?
Sergey_New Well-Known Member Licensed User Longtime User Sep 12, 2023 #5 Andrew (Digitwell) said: What do you mean? Click to expand... After initializing the class, the program will execute some code, after which deinitialization of the class is a condition for continuing the program. The question is simple - is it possible or not to deinitialize a class? Upvote 0
Andrew (Digitwell) said: What do you mean? Click to expand... After initializing the class, the program will execute some code, after which deinitialization of the class is a condition for continuing the program. The question is simple - is it possible or not to deinitialize a class?
sirjo66 Well-Known Member Licensed User Longtime User Sep 12, 2023 #6 try this: B4X: Dim MyClass As MyCustomClass MyClass.Initialize ' ........... other code ' try this for to deinitialize: MyClass = Null Upvote 0
try this: B4X: Dim MyClass As MyCustomClass MyClass.Initialize ' ........... other code ' try this for to deinitialize: MyClass = Null
Sergey_New Well-Known Member Licensed User Longtime User Sep 12, 2023 #7 sirjo66 said: try this: Click to expand... This is the first thing I did. Raises an error after checking B4X: MyClass = Null If MyClass.IsInitialized Then ... I will need to introduce a boolean variable when initializing the class and use it. Last edited: Sep 12, 2023 Upvote 0
sirjo66 said: try this: Click to expand... This is the first thing I did. Raises an error after checking B4X: MyClass = Null If MyClass.IsInitialized Then ... I will need to introduce a boolean variable when initializing the class and use it.
William Lancee Well-Known Member Licensed User Longtime User Sep 12, 2023 #8 If you declare the instance again without initialization, it is not initialized. But it is unusual to need to do this! B4X: Dim sl As SuperList sl.Initialize(Me, "") Log(sl.IsInitialized) 'True Dim sl As SuperList Log(sl.IsInitialized) 'False Upvote 0 Solution
If you declare the instance again without initialization, it is not initialized. But it is unusual to need to do this! B4X: Dim sl As SuperList sl.Initialize(Me, "") Log(sl.IsInitialized) 'True Dim sl As SuperList Log(sl.IsInitialized) 'False
Sergey_New Well-Known Member Licensed User Longtime User Sep 12, 2023 #9 William Lancee said: If you declare the instance again without initialization, it is not initialized. Click to expand... Thank you! I needed this. Upvote 0
William Lancee said: If you declare the instance again without initialization, it is not initialized. Click to expand... Thank you! I needed this.