SynchronizationContext和TaskScheduler都是表示"调度程序"的抽象,是您提供一些工作的东西,它决定了运行该工作的时间和地点.有许多不同形式的调度程序.例如,ThreadPool是一个调度程序:您调用ThreadPool.QueueUserWorkItem来提供一个委托来运行,该委托被排队,并且其中一个ThreadPool的线程最终选择并运行该委托.您的用户界面还有一个调度程序:消息泵.
因此System.Reactive.Concurrency.EventLoopScheduler,Reactive Extensions的Dispatcher,ThreadPool,TaskScheduler,SyncrhonizationContext和IScheduler实现在这个意义上都是"调度程序".
他们之间有什么区别?
他们为什么都是必要的?我想我得到EventLoop,Dispatcher,ThreadPool.IScheduler也有很好的解释.
但是TaskScheduler和SyncrhonizationContext仍然不清楚.
Stephen Cleary的优秀文章解释了SyncrhonizationContext,我想我明白了.那么为什么我们需要TaskScheduler,目前尚不清楚.
请解释或指向消息来源.
c# multithreading conceptual task-parallel-library system.reactive
我需要在服务器端在运行时从随机网页中提取纯文本。我使用Google App Engine和可读性python端口。有很多。
我使用的是Yuri的最新版本,并且似乎正在积极开发中。我设法使它使用Python 2.7在Google App Engine上运行。现在的“问题”是它返回HTML,而我需要纯文本。
这篇Stackoverflow文章中有关链接提取的建议是使用BeatifulSoup。如果没有其他选择,我会的。BeatifulSoup将是另一个依赖项,因为我使用基于lxml的版本。
我的问题:
我尝试使用XML layer-list drawable创建一个简单的插图.
我有两个形状,一个圆形和一个矩形
我想要一个不按比例的圆圈.
以下是布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shape5"
android:layout_gravity="center"
android:scaleType="center"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是shape5.xml drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:top="0dp" android:left="0dp">
<shape android:shape="rectangle" android:scaleType="center">
<stroke android:width="2dp" android:color="@android:color/holo_red_light" />
<size android:width="200dp" android:height="100dp"/>
</shape>
</item>
<item android:top="10dp" android:left="10dp">
<shape android:shape="oval" android:gravity="center" android:scaleType="center" >
<stroke android:width="2dp" android:color="@android:color/holo_blue_light" />
<corners android:radius="10dp" />
<size android:width="20dp" android:height="20dp"/>
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
生成的图形如下所示:

很明显,项目android:top可以完成工作,但没有什么能阻止形状缩放.大小宽度不起作用,android:scaleType ="center"也不起作用.
我快速查看了LayerDrawable.java实现.看起来像在幕后,从项目属性创建插入.所以我想通过计算那些我可以达到结果,我想要的.这是唯一的方法吗?
更新:
根据这个答案,我知道操纵项目的android:top,android:left等,我可以创建一个虚拟插图,可以根据我的需要扩展我的"形状".我查了一遍,这是对的.所以这是一个解决方法.然而,我对它的反直觉感到非常失望.我仍然希望有人能指出我一种简单的方法来禁用缩放.
更新:根据此Google Android文档页面,设置ImageView scaleType应该已禁止缩放.显然在我的情况下,它没有用.缺了点什么.
android ×1
c# ×1
conceptual ×1
layer-list ×1
python ×1
readability ×1
shape ×1
xml ×1
xml-drawable ×1