public virtual void run() { FuNet1 net = new FuNet1(); scheduler.scheduleAtFixedRate(net, 0, 300, TimeUnit.MILLISECONDS); net.Visible = true; }
internal virtual Resource StartPrinting() { ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.ScheduledFuture<?> timerFuture = timer.scheduleAtFixedRate(this::printOnNextUpdate, 0, interactive ? 100 : 5_000, java.util.concurrent.TimeUnit.MILLISECONDS); ScheduledFuture <object> timerFuture = timer.scheduleAtFixedRate(this.printOnNextUpdate, 0, _interactive ? 100 : 5_000, TimeUnit.MILLISECONDS); return(() => { timerFuture.cancel(false); timer.shutdown(); try { timer.awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException) { } Done(); PrintProgress(); }); }
protected internal override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); ContentView = R.layout.activity_office_mover; // Initialize Firebase mFirebaseRef = new Firebase(FIREBASE); // Process authentication Bundle extras = Intent.Extras; string authToken; if (extras != null) { authToken = extras.getString(LoginActivity.AUTH_TOKEN_EXTRA); } else { Log.w(TAG, "Users must be authenticated to do this activity. Redirecting to login activity."); Intent loginIntent = new Intent(ApplicationContext, typeof(LoginActivity)); loginIntent.Flags = Intent.FLAG_ACTIVITY_CLEAR_TOP; startActivity(loginIntent); finish(); return; } mFirebaseRef.authWithOAuthToken("google", authToken, new AuthResultHandlerAnonymousInnerClassHelper(this)); // Initialize the view stuff mOfficeLayout = new OfficeLayout(); mOfficeCanvasView = (OfficeCanvasView)findViewById(R.id.office_canvas); mOfficeCanvasView.OfficeLayout = mOfficeLayout; mOfficeFloorView = (FrameLayout)findViewById(R.id.office_floor); // Listen for floor changes mFirebaseRef.child("background").addValueEventListener(new ValueEventListenerAnonymousInnerClassHelper(this)); // Listen for furniture changes mFirebaseRef.child("furniture").addChildEventListener(new ChildEventListenerAnonymousInnerClassHelper(this)); // Handles menu changes that happen when an office thing is selected or de-selected mOfficeCanvasView.ThingFocusChangeListener = new SelectedThingChangeListenerAnonymousInnerClassHelper(this); // Triggers whenever an office thing changes on the screen. This binds the // user interface to the scheduler that throttles updates to Firebase mOfficeCanvasView.ThingChangedListener = new ThingChangeListenerAnonymousInnerClassHelper(this); // A scheduled executor that throttles updates to Firebase to about 40ms each. // This prevents the high frequency change events from swamping Firebase. ScheduledExecutorService firebaseUpdateScheduler = Executors.newScheduledThreadPool(1); firebaseUpdateScheduler.scheduleAtFixedRate(() => { if (mStuffToUpdate != null && mStuffToUpdate.Count > 0) { foreach (OfficeThing officeThing in mStuffToUpdate.Values) { updateOfficeThing(officeThing.Key, officeThing); mStuffToUpdate.Remove(officeThing.Key); } } }, UPDATE_THROTTLE_DELAY, UPDATE_THROTTLE_DELAY, TimeUnit.MILLISECONDS); }