Read state GPIO by ISR

hello

I have a rock PI4C++

I try to read state GPIO with ISR .

ISR work but i cannot read the state

i always have “Failed to read GPIO 18 state”

if you have an idea Please
thank you

my code c++

#include <iostream>
#include <stdlib.h>
#include <unistd.h>
/* mraa headers */
#include "mraa/common.hpp"
#include "mraa/gpio.hpp"
#define GPIO_PIN 18

void int_handler(void* args)
{
    mraa::Gpio* gpio = static_cast<mraa::Gpio*>(args);
    // Read the state of GPIO 18
    int state = gpio->read();
    std::cout << "ISR triggered" << state << std::endl;
    if (state == 0) {
        std::cout << "ISR triggered: GPIO 18 is LOW" << std::endl;
    } else if (state == 1) {
        std::cout << "ISR triggered: GPIO 18 is HIGH" << std::endl;
    } else {
        std::cerr << "Failed to read GPIO 18 state" << std::endl;
    }
}

int
main(void)

{

    mraa::Result status;
    //! [Interesting]
    /* initialize GPIO */
    mraa::Gpio gpio(GPIO_PIN);
    /* set GPIO to input */
    status = gpio.dir(mraa::DIR_IN);
    if (status != mraa::SUCCESS) {
        printError(status);
        return EXIT_FAILURE;
    }

    /* configure ISR for GPIO */

    status = gpio.isr(mraa::EDGE_BOTH, &int_handler, &gpio);
    if (status != mraa::SUCCESS) {
        printError(status);
        return EXIT_FAILURE;
    }

    /* wait 30 seconds isr trigger */
    while(1)

    {
        sleep(30);
    }

    return EXIT_SUCCESS;

}