Dispatch group notify seems to get called too early

I am trying to use dispatch group as suggested here https://stackoverflow.com/a/35906703/406322

However, it seems like myGroup.notify is being called before all the iterations of the for loop is completed. What am I doing wrong?

let myGroup = DispatchGroup()

for channel in channels.subscribedChannels() {

    buildUser(channel) { (success, user) in
        if success {

        print("Finished request (user.id)")

myGroup.notify(queue: .main) {
    print("Finished all requests.")

The output is this:

Finished request 1
Finished all requests.
Finished request 2

All topic

ArrayList of ActionListeners cleared when notifyListeners() called

I am trying to write a class that both listens for actions from buttons and notifies another class when one of the buttons is pressed. I have an ArrayList and methods addActionListener(ActionListener al), removeActionListener(ActionListener al), and notifyActionListeners(ActionEvent ae). I print to a separate window whenever I add a listener, and print the size of actionListeners as well. It works great and prints that I have 1 actionListener, but then when I try to notify the listeners it says that there are 0 objects in actionListeners. I added a println() to the removeActionListener(al) method to see if it is called, and it never is.
Here’s the class:

package state;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import driver.GameDriver;
import ui.Button;

public class MainMenu extends Menu {
    private static final long serialVersionUID = -7130241947836998525L;

    private ArrayList actionListeners;

    private Button play;
    private Button scores;
    private Button settings;
    private Button help;
    private Button exit;

    public MainMenu() {
        super("Main Menu");
        actionListeners = new ArrayList();


    protected void addComponents() {
        //Irrelevant to Stackexchange

    public void actionPerformed(ActionEvent arg0) {
        Object src = arg0.getSource();
        if (src == play) {
        } else if (src == scores) {
        } else if (src == settings) {
        } else if (src == help) {
        } else if (src == exit) {
            ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_FIRST, "exit");


    public void addActionListener(ActionListener al) {
        GameDriver.println("Added Listener:");

    public void removeActionListener(ActionListener al) {
        GameDriver.println("Removed al for some reason");

    private void notifyActionListeners(ActionEvent ae) {
        GameDriver.println("Sending exit to " + actionListeners.size() + " listeners.");

        for(int i = 0; i < actionListeners.size(); i++) {
            GameDriver.println("Exit sent");


Here are the methods that actually reference the instance of MainMenu:
1. Initialization

protected GameDriver() {
        mainMenu = new MainMenu();
        debugger = new Debugger();
        println("Size Loader Test...");
        println("Window Test...");
        window = new Window("Asteroids");
        windowManager = new WindowManager();
//      window.addWindowFocusListener(windowManager);
//      window.addWindowListener(windowManager);
//      window.addWindowStateListener(windowManager);
        window.buildWindow(SizeLoader.getCurrentWidth(), SizeLoader.getCurrentHeight());
        window.add(new MainMenu());
        println("Menu Test...");


And here's the actionPerformed(ae):

    public void actionPerformed(ActionEvent e) {
        println("Event happened");
        if (e.getSource() == mainMenu) {
            if (e.getActionCommand() == "exit") {
                println("Exiting FR this time...");

All topic

How can I return struct when function is called?

I’d like to return struct type User. However, when I tried the following getUser function, it returns an error. Is there any way that struct data would be returned from a function?


struct User{
    uint256 user_id;
    bytes32 name;
    bytes32 address;
    bytes32 birth_day;
mapping (uint256 => User) public users;

function getUser(uint256 user_id) constant returns (User) {
        return users[user_id];


client/lib/contracts/User.sol: Solidity errors: :125:58: Error: Expected type name

function getUser(uint256 user_id) constant returns (struct User) {

All topic

Long narrative set to music, recorded in oil tank, storm called “Honolulu Lou”

Back in the 60’s I heard a long musical piece that I can’t call a song, rather it was more a story set to music. I can only remember bits of what I heard.

  1. There was a tropical storm in the Pacific called “Honolulu Lou”
  2. There was a wind coming from a piano.
  3. The DJ said it was recorded in an empty oil tank.

That is meager information, but it is all I have.

All topic

Swift 4 prepare(for segue:) not getting called

I have looked at relevant posts and I don’t understand why this is not getting called in my ViewController.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    print("prepare in Start got triggered")

    if segue.destination is RegistrationViewController {

        let newVC = sender as? RegistrationViewController
        newVC?.testString = "Mission accomplished, passed this data"


I call it from a button press

performSegue(withIdentifier: "RegistrationFromStart", sender: self)

testString is a property in RegistrationViewController
the segue happens, no problem, but the property never changes and the prepare never triggers the print command.

I print testString in the viewDidLoad of RegistrationViewController

  print("RegistrationViewController testString (testString)")

Thanks for your help in advance.

All topic

What is the default Debian/Ubuntu console (TTY) font called?

I’m currently running Ubuntu and a few other Linux distributions on my computer and since I use the TTY a lot, a good font is pretty important!

Does anyone know the name of the default console/TTY font used in Ubuntu and Debian?

All topic

JqwidgetGrid(JqxGrid) editor change event getting called recursively causing “Maximum call stack size exceeded” error

I’m trying to add rows to my Jqxgrid dynamically. I have a dropdownlist as an editor for one of the columns. After adding a new row dynamically and then if I change the selection for the editor dropdownlist for the first row, the “change” event gets executed recursively causing “Maximum call stack size exceeded” error. On the change event I’m trying to set the value of a column in the row for which the change was made. This action is actually making recursive calls for the “change” event.
Please share your thoughts to fix this.

columns: [
                        text: 'Fee Type', columntype: 'dropdownlist', datafield: 'FeeType', align: 'left', width: 300, editable: true, sortable: false, columnsresize: true,
                        initeditor: function (row, cellvalue, editor) {

                                source: feeTypeDropdownListAdapter, displayMember: 'Description',
                                valueMember: 'FeeTypeId'

                            editor.bind('select', function (event) {

                                var args = event.args;
                                if (args) {
                                    var item = args.item;
                                    if (item != null) {
                                        var feeTypeID = item.value;
                                        var fundingSource = GetFundingSource(feeTypeID, editor.jqxDropDownList('source').records);
                                        var id = $('#jqxgrid').jqxGrid('getrowid', row);

                                        $("#jqxgrid").jqxGrid('setcellvaluebyid', id, "FundingSource", fundingSource);



                        createeditor: function (row, cellvalue, editor) {



                        text: 'Fee Type', datafield: 'FundingSource', align: 'left', width: 300, editable: true, sortable: false, columnsresize: true

All topic

What is this time loop called?

Like a stable time loop, but when each version of the time traveller goes back in time, they create a history that differs from the previous alternate history? Is there a general term for such an occurrence in science fiction?

All topic

Capturing an event fired from a contract that was called from another contract

I’m trying calculate tax on arbitrary items/values. To do this I have a single contract is used as an ‘Oracle’ to get the tax from an external system. This contract defines functions to be called from other contracts and will emit an event that is captured by the external code. This will then perform the calculations and send the data back to the contract. The code is

pragma solidity ^0.4.21;

contract TaxContract {
    address public owner;
    event TaxRequest(int price);

    constructor() public {
       owner = msg.sender;

    function calculateTax(int price) public {
       emit TaxRequest(price);

The calling contract is passed the address of the TaxContract in it’s constructor.

pragma solidity ^0.4.21;

import "./TaxContract.sol";

// Asset Test Contract
contract AssetContract {
    address public owner;
    address contractAddress;

    // Constructor
    constructor(address taxContractAddress) public {
        owner = msg.sender;
        contractAddress = taxContractAddress;

    // Public functions
    function sellAsset(int price) public {

I’m using Nethereum to both deploy the contracts and listen for events i.e

var sellFunction = contract.GetFunction("sellAsset");
var gasLimit = await sellFunction.EstimateGasAsync().ConfigureAwait(false);
await sellFunction.SendTransactionAndWaitForReceiptAsync(senderAddress, gasLimit, null, null, 563278);


var taxRequestEvent = contract.GetEvent("TaxRequest");
var taxFilter = await taxRequestEvent.CreateFilterAsync();

while (true)
var taxEvent = await taxRequestEvent.GetFilterChanges(taxFilter);

When I had all of the functionality in one contract i.e the sellAsset method emitted the event that the external code was listening for and called the sellAsset function it all worked. But now that I have split it into two separate contracts, no event seems to be fired. Any ideas as to why this is not working?

All topic

Unable to open another Lightning Component in a Modal pop-up when called from within a Lightning app

Here is my first Component called Modal:



Controller for Modal Component looks like this:

    openAnotherComponent: function(component, event, helper) {
        $A.createComponent("c:OpenModal", {},
        function(content, status) {
            if (status === "SUCCESS") {
                    body: content,
                    showCloseButton: false,
                    showCloseButton: true,

My second component which I want to open in a modal pop-up is called OpenModal and here is the code:



Welcome to Modal Box

Controller for OpenModal:

    myAction : function(component, event, helper) {


This code works if Modal component is placed inside a Lightning page. However, if I place it within an app as shown below it errors out.

My App code is as follows:


Here is the error I encounter only if called from an app but not from a lightning page:

This page has an error. You might just need to refresh it. [Cannot
read property ‘ja’ of undefined]

All topic