小编use*_*580的帖子

另一个iframe上的透明iframe

我想要实现的是iframe定位在包含PDF文档的另一个iframe上 - 第一个iframe应该是透明的,它应该覆盖带有PDF的iframe.我需要专门用于IE(9+).

到目前为止我尝试过的代码:

<html>
<head>
<style>
</style>

</head>
<body>

<iframe src="iframeContent.html" frameborder="0" style="width: 1000px; height: 1000px; position: fixed; left:0px; top: 0px; background:transparent" allowTransparency="true"></iframe>

<iframe src='http://www.pdf995.com/samples/pdf.pdf' width="100%" height="300px" id="PDF" name="PDF"></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

iframeContent.html:

<html>
<style type="text/css">

</style>

<body style="background: transparent">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是,上述方法不起作用 - iframe不透明.有谁知道如何解决这个问题?正如我在下面的评论中所说,下面发布的解决方案不适用于安装Adobe Reader DC(如果它可以工作).

html css iframe internet-explorer

11
推荐指数
1
解决办法
2243
查看次数

检查线程是否返回到线程池

如何使用VS C#2015调试器检查线程是否返回到线程池?

在我的情况下,有问题的是它无法通过逐行调试来检测.

async Task foo()
{
    int y = 0;
    await Task.Delay(5);
    // (1) thread 2000 returns to thread pool here...
    while (y<5) y++;
}

async Task testAsync()
{
    Task task = foo();
    // (2) ... and here thread 2000 is back from the thread pool, to run the code below. I want
    // to confirm that it was in the thread pool in the meantime, using debugger.
    int i = 0;
    while (i < 100)
    {
        Console.WriteLine("Async 1 …
Run Code Online (Sandbox Code Playgroud)

c# debugging multithreading async-await

6
推荐指数
1
解决办法
1413
查看次数

UI线程有什么特别之处?

假设我有一个fooCPU同步运行的方法(它不会调用执行I/O的纯异步方法,或者通过调用Task.Run或类似方式使用其他线程来运行其代码).该方法执行一些繁重的计算 - 它受CPU限制.

现在我调用fooCPU我的程序而不委托它由工作线程执行.如果一行fooCPU需要很长时间才能运行,那么在完成之前不会执行任何其他行.因此,例如,从UI线程调用它会导致UI线程冻结(GUI将变得无响应).

当我说这async/await是对多线程的模仿.两个不同代码的行在一个线程上轮流执行.如果这些行中的一行需要很长时间才能运行,则在完成之前不会执行任何其他行.,

我被告知在UI线程上使用async是正确的,但对于所有其他情况(ASP.NET,线程池上的异步,控制台应用程序等)并非如此.

谁能告诉我这可能意味着什么?UI线程与控制台程序的主线程有何不同?

我想在这个论坛上没有人希望任何人继续讨论相关主题,例如它们出现在评论中,所以最好提出一个新问题.

c# multithreading async-await

6
推荐指数
2
解决办法
1408
查看次数

当前的SynchronizationContext可以为null吗?

https://msdn.microsoft.com/en-us/magazine/gg598924.aspx

这是一篇很棒的文章,我知道所有细节都无法涵盖,因为这实际上涉及粘贴.NET框架的源代码.所以引用文字:

每个线程都有一个当前上下文.如果"Current"为null,则按照惯例,线程的当前上下文为"new SynchronizationContext()".

但另一方面:

默认情况下,当前的SynchronizationContext是在await点捕获的,并且此SynchronizationContext用于在await之后恢复(更确切地说,它捕获当前的SynchronizationContext, 除非它为null,在这种情况下它捕获当前的TaskScheduler)

这两个陈述相互矛盾,所以我认为这是作者做出的一些简化的结果(我很好).

有人能解释一下吗?代码可能有助于回答我的问题(查找syncCtx变量),这段代码与第二个引用相关.

c# multithreading synchronizationcontext

5
推荐指数
1
解决办法
632
查看次数

JScrollPane - 它如何显示 JTable 标题?

JScrollPane 代码的哪一部分负责显示 JTable 的列标题?

如果您只是将 JTable 添加到 JPanel,默认情况下它不会显示标题。您应该将表传递给 JScrollPane 的构造函数,或者使用setViewportView表作为参数调用 JScrollPane。那么实际上,是什么让列标题可见呢?它是 JScrollPane (updateUIgetUI方法)内部渲染的一部分吗?

最初我以为 JScrollPane 使用它setColumnHeaderView来完成此操作,但事实并非如此(将 null 传递给此方法,表格仍将显示标题)。

java swing jtable jscrollpane

5
推荐指数
1
解决办法
647
查看次数

使用async/await时,GUI会冻结

我想弄清楚下面的代码有什么问题.我认为使用async和await让我忘记了诸如冻结之类的GUI问题,因为一些长代码阻塞了主线程.

单击按钮后,GUI响应,直到调用longRunningMethod,如下所示:

 private async void openButton_Click(object sender, RoutedEventArgs e)
 {
    //doing some usual stuff before calling downloadFiles
    Task<int> result = await longRunningMethod(); // async method

    //at this point GUI becomes unresponsive

    //I'm using the result here, so I can't proceed until the longRunningMethod finishes

  }
Run Code Online (Sandbox Code Playgroud)

在方法完成之前我无法继续,因为我需要result.为什么这段代码会冻结我的应用?

c# wpf async-await

3
推荐指数
1
解决办法
2043
查看次数

多个角度选择 - 更改一个值会影响下一个选择

在以下场景中我遇到了奇怪的行为。选择集合允许您配置myCars从可用汽车列表中选择的汽车列表 ( )。

<div *ngFor="let car of myCars; let i = index;">
    <mat-form-field>
        <mat-label>Car</mat-label>
        <mat-select [(value)]="myCars[i]" (selectionChange)="selectionChanged($event, i)">
            <mat-option>-</mat-option>
            <mat-option *ngFor="let car of carsAvailable" [value]="car">{{car.name}}</mat-option>
        </mat-select>
    </mat-form-field>
</div>
<button mat-raised-button color="primary" type="button" (click)="addNewCar()">Add new car</button>
Run Code Online (Sandbox Code Playgroud)

问题是,当我的列表中有两辆车时,例如:

Select1 : Ferrari
Select2 : Ferrari
Run Code Online (Sandbox Code Playgroud)

并将 的值更改Select1Audi,两个选择都错误地设置为该值:

Select1 : Audi
Select2 : Audi
Run Code Online (Sandbox Code Playgroud)

但是 myCars 数组包含[Ferrari, Audi],这是正确的。有趣的是,如果我选择奥迪select2select1则将保持不变。即使我有 10 个相同的选择,其中选择了 Ferrari,并将第 i 个选择更改为 Audi,也只有第 i+1 个选择会更改为 Audi。

你们中有人能解释为什么会发生这种情况吗?对我来说,这看起来像是某种竞争条件,其中与第 i 个选择对应的 DOM 项首先被删除,并且 …

angular-material angular

3
推荐指数
1
解决办法
1654
查看次数

使用await时线程返回线程池

但是,使用ASP.NET Web Api,如果您的请求是在一个线程上进行的,并且等待某些函数和调用ConfigureAwait(false) ,则在返回ApiController函数的最终结果时可能会将您置于不同的线程上.

实际上,只是做一个await可以做到这一点.一旦你的async方法遇到一个await,该方法被阻止但线程返回到线程池.当方法准备好继续时,从线程池中抢夺任何线程并用于恢复该方法.

资源

我刚刚在控制台程序中测试过:

async Task foo()
{
    int y = 0;
    while (y<5) y++;
}

async Task testAsync()
{
    int i = 0;
    while (i < 100)
    {
        Console.WriteLine("Async 1 before: " + i++);

    }
    await foo();

    while (i < 105)
    {
        i++;
        Console.WriteLine("Async 1 after: " + i);
    }
}
Run Code Online (Sandbox Code Playgroud)

调用await foo()不会导致线程testAsync运行返回到线程池,testAsync只是从头到尾在同一个线程上逐行运行.我在这里错过了什么?

c# multithreading async-await

0
推荐指数
1
解决办法
495
查看次数