In some cases, a class of theorems called Tauberian theorems can help you to justify interchanging the order of two limiting operators. For example, if the improper integral $\int_{0}^{\infty} f(x) \, dx$ exists, then
$$\int_{0}^{\infty} \int_{0}^{\infty} x^{n} s^{n-1} f(x) \; e^{-xs} \, ds dx = \int_{0}^{\infty} \int_{0}^{\infty} x^{n} s^{n-1} f(x) \; e^{-xs} \, dx ds$$
holds for all $n$. (Of course, existence of both iterated integrals are also guaranteed.) Originally, Tauberian theorems are answers to the following question: For what condition (Tauberian condition) ensures that a stronger summability method implies a weaker summability? Since a stronger summability method often exploits a good approximation to the identity, these theorems may be regarded as a special kind of interchanging the order of limiting operators. For example, a function $f(x)$ is Abel-summable to $I$ if
$$\lim_{\delta \to 0+} \int_{0}^{\infty} f(x) e^{-\delta x} \, dx$$
exists with the value $I$. Then this reduces to the ordinary summability if we have
$$\lim_{\delta \to 0+} \int_{0}^{\infty} f(x) e^{-\delta x} \, dx =
\int_{0}^{\infty} f(x) \, dx = \int_{0}^{\infty} \lim_{\delta \to 0+} f(x) e^{-\delta x} \, dx.$$
For the integral in question, we may understand it as the Cauchy principal value. That is, we identify this integral with
$$ \lim_{\epsilon \to 0+} \sum_{n=1}^{\infty} \int_{\pi(n-1) + \epsilon}^{ \pi n - \epsilon} \frac{e^{-x}}{\sin x} \, dx.$$
By circumventing poles, this integral can be managed by several techniques.