Beispiel #1
0
        private static async Task UpdateAsync <T>(T item)
            where T : class
        {
            await Semaphore.WaitAsync();

            await Task.Run(() =>
            {
                using (var provider = new SqliteDataProvider(StorePath))
                {
                    using (var context = new Vx.Context(provider))
                    {
                        context.Update <T>(item, true);
                    }
                }
            }).ConfigureAwait(false);

            Semaphore.Release();
        }
Beispiel #2
0
        internal static async Task MarkMessagesAsSeenAsync()
        {
            await Task.Run(() =>
            {
                using (var provider = new SqliteDataProvider(StorePath))
                {
                    using (var context = new Vx.Context(provider))
                    {
                        var q = from message in context.DataSet <ChatMessage>()
                                where !message.IsSeen
                                select message;

                        foreach (var message in q)
                        {
                            message.IsSeen = true;
                            context.Update(message);
                        }
                    }
                }
            }).ConfigureAwait(false);
        }