2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Concurrent;
19 using System.ComponentModel;
20 using System.Threading;
22 namespace Tizen.Applications
25 /// Provides a synchronization context for the Tizen thread application model.
27 /// <since_tizen> 10 </since_tizen>
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class TizenUISynchronizationContext : SynchronizationContext
32 /// Initilizes a new TizenUISynchronizationContext and install into the current thread.
37 /// SetSynchronizationContext(new TizenUISynchronizationContext());
40 /// <since_tizen> 10 </since_tizen>
41 public static void Initialize()
43 SetSynchronizationContext(new TizenUISynchronizationContext());
47 /// Dispatches an asynchronous message to a Tizen main loop of the UI thread.
49 /// <param name="d"><see cref="System.Threading.SendOrPostCallback"/>The SendOrPostCallback delegate to call.</param>
50 /// <param name="state"><see cref="System.Object"/>The object passed to the delegate.</param>
52 /// The post method starts an asynchronous request to post a message.</remarks>
53 /// <since_tizen> 10 </since_tizen>
54 public override void Post(SendOrPostCallback d, object state)
56 GSourceManager.Post(() =>
63 /// Dispatches a synchronous message to a Tizen main loop of the UI thread.
65 /// <param name="d"><see cref="System.Threading.SendOrPostCallback"/>The SendOrPostCallback delegate to call.</param>
66 /// <param name="state"><see cref="System.Object"/>The object passed to the delegate.</param>
68 /// The send method starts a synchronous request to send a message.</remarks>
69 /// <since_tizen> 10 </since_tizen>
70 public override void Send(SendOrPostCallback d, object state)
72 using (var mre = new ManualResetEvent(false))
75 GSourceManager.Post(() =>
77 #pragma warning disable CA1031
90 #pragma warning restore CA1031