Question: We need to load test an web application using `SignalR` in few components with transport mode as long polling. My script gets hang in connect step. Connect step is `GET- /signalr/connect?transport=foreverFrame&clientProtocol=1.5&connectionToken=ZW6cj17pImmCjGGBQSQNy%2Bdiy7DKDUy4i4R1AE78c%2FTitzS6QgiPoX6fM3zBOrDK11hyx0QNEc92JM6bsLY19MCt5JjaYFgdTDVsbxfnRbkqKp6dpsl64BV1zI8Vu1X%2F&connectionData=%5B%7B%22name%22%3A%22mypreviewhub%22%7D%5D&tid=10&frameId=1`

I have correlated following 2 parameters- 1) captured connection token from negotiate step and used in subsequent requests 
2) used `${__time()}` for timestamp as found in link- [How to capture signalR connection string in Jmeter](https://stackoverflow.com/questions/49648779/how-to-capture-signalr-connection-string-in-jmeter/52273372#52273372)

Apart from these, I can see 2 more parameters being send in connect step- tid and frameid. Do we need to correlate these 2 parameters as well, although these are not used anywhere else apart from connect step?

Or what is that my script lacking? 

In various posts, I have seen suggestions to use websocket sampler plugins but I believe that can be helpful, if your SignalR use websocket mechanism, not long polling.

Please help me resolve this issue. Your help is appreciated. Thanks

Answer: 
Use a for loop over [Map.entries](https://api.dartlang.org/stable/2.0.0/dart-core/Map/entries.html) instead of forEach. Provided you are in an async function, await-ing in the body of a for loop will pause the iteration. The entry object will also allow you to access both the key and value.

```
Future<void> myFunction() async {
  for (var entry in myMap.entries) {
    await myAsyncFunction(entry.key, entry.value);
  }
  callFunc();
}

```
You could also use `map` like:

```
const futures = myMap.map((a, b) => myAsyncFunc());
await Future.wait(futures);
callFunc();

```