[InputMethod] Remove lock from InputMethodEditor (#671)
authorInhong <tukkong123@naver.com>
Mon, 21 Jan 2019 02:04:46 +0000 (11:04 +0900)
committerGitHub <noreply@github.com>
Mon, 21 Jan 2019 02:04:46 +0000 (11:04 +0900)
IME does not need to consider multi-threading.

src/Tizen.Uix.InputMethod/Tizen.Uix.InputMethod/InputMethodEditor.cs

index f02f687eedda280ccc333fd34b702b5d5c5bac4b..0e3c8f2dcd6547378f363f349286a3b84543293a 100755 (executable)
@@ -960,7 +960,6 @@ namespace Tizen.Uix.InputMethod
     /// <since_tizen> 4 </since_tizen>
     public static class InputMethodEditor
     {
-        private static Object thisLock = new Object();
         private static ImeCallbackStructGCHandle _imeCallbackStructGCHandle = new ImeCallbackStructGCHandle();
         private static event EventHandler<FocusedInEventArgs> _focusIn;
         private static ImeFocusedInCb _imeFocusedInDelegate;
@@ -1125,30 +1124,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeFocusedInDelegate = (int contextId, IntPtr userData) =>
                 {
-                    _imeFocusedInDelegate = (int contextId, IntPtr userData) =>
-                    {
-                        FocusedInEventArgs args = new FocusedInEventArgs(contextId);
-                        _focusIn?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetFocusedInCb(_imeFocusedInDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add FocusedIn Failed with error " + error);
-                    }
-                    else
-                    {
-                        _focusIn += value;
-                    }
+                    FocusedInEventArgs args = new FocusedInEventArgs(contextId);
+                    _focusIn?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetFocusedInCb(_imeFocusedInDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add FocusedIn Failed with error " + error);
+                }
+                else
+                {
+                    _focusIn += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _focusIn -= value;
-                }
+                _focusIn -= value;
             }
         }
 
@@ -1160,30 +1153,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeFocusedOutDelegate = (int contextId, IntPtr userData) =>
                 {
-                    _imeFocusedOutDelegate = (int contextId, IntPtr userData) =>
-                    {
-                        FocusedOutEventArgs args = new FocusedOutEventArgs(contextId);
-                        _focusOut?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetFocusedOutCb(_imeFocusedOutDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add FocusedOut Failed with error " + error);
-                    }
-                    else
-                    {
-                        _focusOut += value;
-                    }
+                    FocusedOutEventArgs args = new FocusedOutEventArgs(contextId);
+                    _focusOut?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetFocusedOutCb(_imeFocusedOutDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add FocusedOut Failed with error " + error);
+                }
+                else
+                {
+                    _focusOut += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _focusOut -= value;
-                }
+                _focusOut -= value;
             }
         }
 
@@ -1195,30 +1182,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
                 {
-                    _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
-                    {
-                        SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
-                        _surroundingTextUpdated?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
-                    }
-                    else
-                    {
-                        _surroundingTextUpdated += value;
-                    }
+                    SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
+                    _surroundingTextUpdated?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
+                }
+                else
+                {
+                    _surroundingTextUpdated += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _surroundingTextUpdated -= value;
-                }
+                _surroundingTextUpdated -= value;
             }
         }
 
@@ -1230,29 +1211,23 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeInputContextResetDelegate = (IntPtr userData) =>
                 {
-                    _imeInputContextResetDelegate = (IntPtr userData) =>
-                    {
-                        _inputContextReset?.Invoke(null, EventArgs.Empty);
-                    };
-                    ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
-                    }
-                    else
-                    {
-                        _inputContextReset += value;
-                    }
+                    _inputContextReset?.Invoke(null, EventArgs.Empty);
+                };
+                ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
+                }
+                else
+                {
+                    _inputContextReset += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _inputContextReset -= value;
-                }
+                _inputContextReset -= value;
             }
         }
 
@@ -1264,30 +1239,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
                 {
-                    _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
-                    {
-                        CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
-                        _cursorPositionUpdated?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
-                    }
-                    else
-                    {
-                        _cursorPositionUpdated += value;
-                    }
+                    CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
+                    _cursorPositionUpdated?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
+                }
+                else
+                {
+                    _cursorPositionUpdated += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _cursorPositionUpdated -= value;
-                }
+                _cursorPositionUpdated -= value;
             }
         }
 
@@ -1300,30 +1269,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeLanguageSetDelegate = (InputPanelLanguage language, IntPtr userData) =>
                 {
-                    _imeLanguageSetDelegate = (InputPanelLanguage language, IntPtr userData) =>
-                    {
-                        LanguageSetEventArgs args = new LanguageSetEventArgs(language);
-                        _langaugeSet?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetLanguageSetCb(_imeLanguageSetDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add LanguageSet Failed with error " + error);
-                    }
-                    else
-                    {
-                        _langaugeSet += value;
-                    }
+                    LanguageSetEventArgs args = new LanguageSetEventArgs(language);
+                    _langaugeSet?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetLanguageSetCb(_imeLanguageSetDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add LanguageSet Failed with error " + error);
+                }
+                else
+                {
+                    _langaugeSet += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _langaugeSet -= value;
-                }
+                _langaugeSet -= value;
             }
         }
 
@@ -1335,32 +1298,26 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
                 {
-                    _imeDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
-                    {
-                        byte[] destination = new byte[dataLength];
-                        Marshal.Copy(data, destination, 0, (int)dataLength);
-                        SetDataEventArgs args = new SetDataEventArgs(destination, dataLength);
-                        _imDataSet?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetImdataSetCb(_imeDataSetDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add DataSet Failed with error " + error);
-                    }
-                    else
-                    {
-                        _imDataSet += value;
-                    }
+                    byte[] destination = new byte[dataLength];
+                    Marshal.Copy(data, destination, 0, (int)dataLength);
+                    SetDataEventArgs args = new SetDataEventArgs(destination, dataLength);
+                    _imDataSet?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetImdataSetCb(_imeDataSetDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add DataSet Failed with error " + error);
+                }
+                else
+                {
+                    _imDataSet += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _imDataSet -= value;
-                }
+                _imDataSet -= value;
             }
         }
 
@@ -1373,30 +1330,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeLayoutSetDelegate = (InputPanelLayout layout, IntPtr userData) =>
                 {
-                    _imeLayoutSetDelegate = (InputPanelLayout layout, IntPtr userData) =>
-                    {
-                        LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
-                        _layoutSet?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
-                    }
-                    else
-                    {
-                        _layoutSet += value;
-                    }
+                    LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
+                    _layoutSet?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
+                }
+                else
+                {
+                    _layoutSet += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _layoutSet -= value;
-                }
+                _layoutSet -= value;
             }
         }
 
@@ -1409,30 +1360,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeReturnKeySetDelegate = (InputPanelReturnKey type, IntPtr userData) =>
                 {
-                    _imeReturnKeySetDelegate = (InputPanelReturnKey type, IntPtr userData) =>
-                    {
-                        ReturnKeySetEventArgs args = new ReturnKeySetEventArgs(type);
-                        _returnKeyTypeSet?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetReturnKeySetCb(_imeReturnKeySetDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add ReturnKeySet Failed with error " + error);
-                    }
-                    else
-                    {
-                        _returnKeyTypeSet += value;
-                    }
+                    ReturnKeySetEventArgs args = new ReturnKeySetEventArgs(type);
+                    _returnKeyTypeSet?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetReturnKeySetCb(_imeReturnKeySetDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add ReturnKeySet Failed with error " + error);
+                }
+                else
+                {
+                    _returnKeyTypeSet += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _returnKeyTypeSet -= value;
-                }
+                _returnKeyTypeSet -= value;
             }
         }
 
@@ -1444,30 +1389,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
                 {
-                    _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
-                    {
-                        ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
-                        _returnKeyStateSet?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
-                    }
-                    else
-                    {
-                        _returnKeyStateSet += value;
-                    }
+                    ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
+                    _returnKeyStateSet?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
+                }
+                else
+                {
+                    _returnKeyStateSet += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _returnKeyStateSet -= value;
-                }
+                _returnKeyStateSet -= value;
             }
         }
 
@@ -1479,30 +1418,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeDisplayLanguageChangedDelegate = (IntPtr language, IntPtr userData) =>
                 {
-                    _imeDisplayLanguageChangedDelegate = (IntPtr language, IntPtr userData) =>
-                    {
-                        DisplayLanguageChangedEventArgs args = new DisplayLanguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
-                        _displayLanguageChanged?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanguageChangedDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add DisplayLanguageChanged Failed with error " + error);
-                    }
-                    else
-                    {
-                        _displayLanguageChanged += value;
-                    }
+                    DisplayLanguageChangedEventArgs args = new DisplayLanguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
+                    _displayLanguageChanged?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanguageChangedDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add DisplayLanguageChanged Failed with error " + error);
+                }
+                else
+                {
+                    _displayLanguageChanged += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _displayLanguageChanged -= value;
-                }
+                _displayLanguageChanged -= value;
             }
         }
 
@@ -1514,30 +1447,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeRotationChangedDelegate = (int degree, IntPtr userData) =>
                 {
-                    _imeRotationChangedDelegate = (int degree, IntPtr userData) =>
-                    {
-                        RotationChangedEventArgs args = new RotationChangedEventArgs(degree);
-                        _rotationDegreeChanged?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetRotationChangedCb(_imeRotationChangedDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add RotationChanged Failed with error " + error);
-                    }
-                    else
-                    {
-                        _rotationDegreeChanged += value;
-                    }
+                    RotationChangedEventArgs args = new RotationChangedEventArgs(degree);
+                    _rotationDegreeChanged?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetRotationChangedCb(_imeRotationChangedDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add RotationChanged Failed with error " + error);
+                }
+                else
+                {
+                    _rotationDegreeChanged += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _rotationDegreeChanged -= value;
-                }
+                _rotationDegreeChanged -= value;
             }
         }
 
@@ -1549,30 +1476,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
                 {
-                    _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
-                    {
-                        AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
-                        _accessibilityStateChanged?.Invoke(null, args);
-                    };
-                    ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
-                    if (error != ErrorCode.None)
-                    {
-                        Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
-                    }
-                    else
-                    {
-                        _accessibilityStateChanged += value;
-                    }
+                    AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
+                    _accessibilityStateChanged?.Invoke(null, args);
+                };
+                ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
+                if (error != ErrorCode.None)
+                {
+                    Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
+                }
+                else
+                {
+                    _accessibilityStateChanged += value;
                 }
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _accessibilityStateChanged -= value;
-                }
+                _accessibilityStateChanged -= value;
             }
         }
 
@@ -2250,30 +2171,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                if (_imePredictionHintSetDelegate == null)
                 {
-                    if (_imePredictionHintSetDelegate == null)
+                    _imePredictionHintSetDelegate = (IntPtr predictionHint, IntPtr userData) =>
                     {
-                        _imePredictionHintSetDelegate = (IntPtr predictionHint, IntPtr userData) =>
-                        {
-                            PredictionHintUpdatedEventArgs args = new PredictionHintUpdatedEventArgs(Marshal.PtrToStringAnsi(predictionHint));
-                            _predictionHintUpdated?.Invoke(null, args);
-                        };
-                        ErrorCode error = ImeEventSetPredictionHintSetCb(_imePredictionHintSetDelegate, IntPtr.Zero);
-                        if (error != ErrorCode.None)
-                        {
-                            Log.Error(LogTag, "Add PredictionHintUpdated Failed with error " + error);
-                        }
+                        PredictionHintUpdatedEventArgs args = new PredictionHintUpdatedEventArgs(Marshal.PtrToStringAnsi(predictionHint));
+                        _predictionHintUpdated?.Invoke(null, args);
+                    };
+                    ErrorCode error = ImeEventSetPredictionHintSetCb(_imePredictionHintSetDelegate, IntPtr.Zero);
+                    if (error != ErrorCode.None)
+                    {
+                        Log.Error(LogTag, "Add PredictionHintUpdated Failed with error " + error);
                     }
-                    _predictionHintUpdated += value;
                 }
+                _predictionHintUpdated += value;
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _predictionHintUpdated -= value;
-                }
+                _predictionHintUpdated -= value;
             }
         }
 
@@ -2285,31 +2200,25 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                if (_imePredictionHintDataSetDelegate == null)
                 {
-                    if (_imePredictionHintDataSetDelegate == null)
+                    _imePredictionHintDataSetDelegate = (IntPtr key, IntPtr keyValue, IntPtr userData) =>
                     {
-                        _imePredictionHintDataSetDelegate = (IntPtr key, IntPtr keyValue, IntPtr userData) =>
-                        {
-                            PredictionHintDataUpdatedEventArgs args = new PredictionHintDataUpdatedEventArgs(Marshal.PtrToStringAnsi(key), Marshal.PtrToStringAnsi(keyValue));
-                            _predictionHintDataUpdated?.Invoke(null, args);
-                        };
-
-                        ErrorCode error = ImeEventSetPredictionHintDataSetCb(_imePredictionHintDataSetDelegate, IntPtr.Zero);
-                        if (error != ErrorCode.None)
-                        {
-                            Log.Error(LogTag, "Add PredictionHintDataUpdated Failed with error " + error);
-                        }
+                        PredictionHintDataUpdatedEventArgs args = new PredictionHintDataUpdatedEventArgs(Marshal.PtrToStringAnsi(key), Marshal.PtrToStringAnsi(keyValue));
+                        _predictionHintDataUpdated?.Invoke(null, args);
+                    };
+
+                    ErrorCode error = ImeEventSetPredictionHintDataSetCb(_imePredictionHintDataSetDelegate, IntPtr.Zero);
+                    if (error != ErrorCode.None)
+                    {
+                        Log.Error(LogTag, "Add PredictionHintDataUpdated Failed with error " + error);
                     }
-                    _predictionHintDataUpdated += value;
                 }
+                _predictionHintDataUpdated += value;
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _predictionHintDataUpdated -= value;
-                }
+                _predictionHintDataUpdated -= value;
             }
         }
 
@@ -2321,30 +2230,24 @@ namespace Tizen.Uix.InputMethod
         {
             add
             {
-                lock (thisLock)
+                if (_imeMimeTypeSetRequestDelegate == null)
                 {
-                    if (_imeMimeTypeSetRequestDelegate == null)
+                    _imeMimeTypeSetRequestDelegate = (IntPtr mimeType, IntPtr userData) =>
                     {
-                        _imeMimeTypeSetRequestDelegate = (IntPtr mimeType, IntPtr userData) =>
-                        {
-                            MimeTypeUpdateRequestedEventArgs args = new MimeTypeUpdateRequestedEventArgs(Marshal.PtrToStringAnsi(mimeType));
-                            _mimeTypeUpdateRequested?.Invoke(null, args);
-                        };
-                        ErrorCode error = ImeEventSetMimeTypeSetRequestCb(_imeMimeTypeSetRequestDelegate, IntPtr.Zero);
-                        if (error != ErrorCode.None)
-                        {
-                            Log.Error(LogTag, "Add MimeTypeUpdateRequested Failed with error " + error);
-                        }
+                        MimeTypeUpdateRequestedEventArgs args = new MimeTypeUpdateRequestedEventArgs(Marshal.PtrToStringAnsi(mimeType));
+                        _mimeTypeUpdateRequested?.Invoke(null, args);
+                    };
+                    ErrorCode error = ImeEventSetMimeTypeSetRequestCb(_imeMimeTypeSetRequestDelegate, IntPtr.Zero);
+                    if (error != ErrorCode.None)
+                    {
+                        Log.Error(LogTag, "Add MimeTypeUpdateRequested Failed with error " + error);
                     }
-                    _mimeTypeUpdateRequested += value;
                 }
+                _mimeTypeUpdateRequested += value;
             }
             remove
             {
-                lock (thisLock)
-                {
-                    _mimeTypeUpdateRequested -= value;
-                }
+                _mimeTypeUpdateRequested -= value;
             }
         }