Example #1
0
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            UsbStreamAsyncTransfer asyncTransfer = new UsbStreamAsyncTransfer(mUsbEndpoint, buffer, offset, count, callback, state, ReadTimeout);

            WaitThread.Start(asyncTransfer);
            return(asyncTransfer);
        }
        /// <summary>
        /// Removes the wait thread from the list.
        /// </summary>
        /// <param name="thread">The wait thread to remove from the list.</param>
        private void RemoveWaitThread(WaitThread thread)
        {
            WaitThreadNode?current = _waitThreadsHead !;

            if (current.Thread == thread)
            {
                _waitThreadsHead = current.Next;
                return;
            }

            WaitThreadNode prev;

            do
            {
                prev    = current;
                current = current.Next;
            } while (current != null && current.Thread != thread);

            Debug.Assert(current != null, "The wait thread to remove was not found in the list of thread pool wait threads.");

            if (current != null)
            {
                prev.Next = current.Next;
            }
        }
Example #3
0
 internal void Service_Error(object serder, ErrorEventArgs e)
 {
     if (WaitThread != null)
     {
         WaitThread.Set();
     }
     ShowError(e.Exception);
 }
 /// <summary>
 /// Attempt to remove the given wait thread from the list. It is only removed if there are no user-provided waits on the thread.
 /// </summary>
 /// <param name="thread">The thread to remove.</param>
 /// <returns><c>true</c> if the thread was successfully removed; otherwise, <c>false</c></returns>
 private bool TryRemoveWaitThread(WaitThread thread)
 {
     _waitThreadLock.Acquire();
     try
     {
         if (thread.AnyUserWaits)
         {
             return(false);
         }
         RemoveWaitThread(thread);
     }
     finally
     {
         _waitThreadLock.Release();
     }
     return(true);
 }
Example #5
0
        private void DoCreate()
        {
            if (string.IsNullOrEmpty(View.txtName.Text))
            {
                MessageBox.Show("Type in the name of this place.", "MySquare", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }
            Cursor.Current = Cursors.WaitCursor;


            double lat = 0, lng = 0;
            double?latSel  = View.latitudeSelected;
            double?longSel = View.longitudeSelected;

            if (latSel.HasValue && longSel.HasValue)
            {
                lat = latSel.Value;
                lng = longSel.Value;
            }
            else if (!Program.Location.WorldPoint.IsEmpty)
            {
                lat = Program.Location.WorldPoint.Latitude;
                lng = Program.Location.WorldPoint.Longitude;
            }

            createdVenue = null;
            Service.AddVenue(
                View.txtName.Text, View.txtAddress.Text, View.txtCross.Text,
                View.txtCity.Text, View.txtState.Text, View.txtZip.Text,
                View.txtPhone.Text, lat, lng, null);
            WaitThread.Reset();
            WaitThread.WaitOne();
            Cursor.Current = Cursors.Default;

            if (createdVenue != null)
            {
                MessageBox.Show(string.Format("{0} was created.", View.txtName.Text), "MySquare", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                (OpenController(((Main)View.Parent).venueDetails1) as VenueDetailsController).OpenVenue(createdVenue);
                createdVenue = null;
            }
            else
            {
                MessageBox.Show(string.Format("{0} was not created.", View.txtName.Text), "MySquare", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }
        internal void DoCheckIn()
        {
            waitingCheckIn = true;
            View.checkIn1.pnlShout.Enabled = false;
            View.tabStrip1.Enabled         = false;

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            bool?twitter  = null;
            bool?facebook = null;

            if (View.checkIn1.chkTwitter.CheckState != CheckState.Indeterminate)
            {
                twitter = View.checkIn1.chkTwitter.CheckState == CheckState.Checked;
            }
            if (View.checkIn1.chkFacebook.CheckState != CheckState.Indeterminate)
            {
                facebook = View.checkIn1.chkFacebook.CheckState == CheckState.Checked;
            }

            checkInResult = null;
            WaitThread.Reset();
            if (!Program.Location.WorldPoint.IsEmpty && Program.Location.FixType == RisingMobility.Mobile.Location.FixType.Gps)
            {
                Service.CheckIn(Venue,
                                View.checkIn1.txtShout.Text,
                                View.checkIn1.chkTellFriends.Checked,
                                facebook, twitter,
                                Program.Location.WorldPoint.Latitude,
                                Program.Location.WorldPoint.Longitude,
                                Program.Location.WorldPoint.Altitude,
                                Program.Location.WorldPoint.HorizontalDistance);
            }
            else
            {
                Service.CheckIn(Venue,
                                View.checkIn1.txtShout.Text,
                                View.checkIn1.chkTellFriends.Checked,
                                facebook, twitter);
            }
            RightSoftButtonText = "&Cancel";
        }
Example #7
0
 public override void OnEnter()
 {
     IsInitialized = true;
     WaitThread.Start();
     base.OnEnter();
 }
 public WaitThreadNode(WaitThread thread) => Thread = thread;
Example #9
0
 public void AddWaitingThread(WaitThread WaitThread)
 {
     _WaitingThreads.Add(WaitThread);
     UpdateWaitingThreads();
 }
Example #10
0
 void Service_VenueResult(object sender, VenueEventArgs e)
 {
     createdVenue = e.Venue;
     WaitThread.Set();
 }
Example #11
0
 void Service_Error(object serder, MySquare.Service.ErrorEventArgs e)
 {
     WaitThread.Set();
 }
Example #12
0
 public void AddWaitingThread(WaitThread WaitThread)
 {
     WaitingThreads.Add(WaitThread);
     UpdateWaitingThreads();
 }