コード例 #1
0
ファイル: Form1.cs プロジェクト: yanglr/dotNET-Gotchas
        private void DelegateButton_Click(
            object sender, System.EventArgs e)
        {
            AsynchDelegate dlg
                = new AsynchDelegate(AsynchExecuted);

            dlg.BeginInvoke(null, null);
        }
コード例 #2
0
        public void AsynchLogUserRegistration(Guid?userId, string ip)
        {
            var userRegistrationLog = new UserRegistrationLog
            {
                UserId    = userId.Value,
                IpAddress = ip,
                DateTime  = DateTime.Now
            };

            AsynchDelegate aDelegate = () =>
            {
                DataService.PerThread.UserRegistrationLogSet.AddObject(userRegistrationLog);
                DataService.PerThread.SaveChanges();
            };

            var asynchRes = aDelegate.BeginInvoke(null, null);

            aDelegate.EndInvoke(asynchRes);
        }
コード例 #3
0
        public void AsynchLogUserAuthentification(string userName, string ip, bool status)
        {
            var userAuthentificationLog = new UserAuthentificationLog
            {
                UserName  = userName,
                IpAddress = ip,
                Status    = status,
                DateTime  = DateTime.Now
            };

            AsynchDelegate aDelegate = () =>
            {
                DataService.PerThread.UserAuthentificationLogSet.AddObject(userAuthentificationLog);
                DataService.PerThread.SaveChanges();
            };

            var asynchRes = aDelegate.BeginInvoke(null, null);

            aDelegate.EndInvoke(asynchRes);
        }
コード例 #4
0
        public void AsynchLogUserPollVote(Guid?userId, Guid groupMemberId, Guid pollId, string result)
        {
            var userPollVoteLog = new UserPollVoteLog
            {
                UserId        = userId.Value,
                GroupMemberId = groupMemberId,
                PollId        = pollId,
                Result        = result,
                DateTime      = DateTime.Now
            };

            AsynchDelegate aDelegate = () =>
            {
                DataService.PerThread.UserPollVoteLogSet.AddObject(userPollVoteLog);
                DataService.PerThread.SaveChanges();
            };

            var asynchRes = aDelegate.BeginInvoke(null, null);

            aDelegate.EndInvoke(asynchRes);
        }