我正在编写一个 WinForm 组件,在那里我启动一个任务来进行实际处理并在继续时捕获异常。从那里我想在 UI 元素上显示异常消息。
Task myTask = Task.Factory.StartNew (() => SomeMethod(someArgs));
myTask.ContinueWith (antecedant => uiTextBox.Text = antecedant.Exception.Message,
TaskContinuationOptions.OnlyOnFaulted);
Run Code Online (Sandbox Code Playgroud)
现在我收到一个跨线程异常,因为该任务正在尝试从一个明显的非 UI 线程更新 UI 元素。
但是,在 Component 类中没有定义 Invoke 或 BeginInvoke。
如何从这里开始?
更新
另外,请注意 Invoke/BeginInvoke/InvokeRequired 在我的 Component 派生类中不可用,因为 Component 不提供它们。
我有以下组件,其中包含从自定义类派生的属性:
unit MyComponentTest3;
interface
uses Windows, ExtCtrls,Classes,Controls;
type
TMyClass3 = class
myString: string;
myNumber: double;
end;
TMyComponentTest3 = class(TCustomPanel)
private
FMyProperty: TMyClass3;
procedure SetMyProperty(Value: TMyClass3);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetMyPropertyPublic(AmyString: string; AmyNumber: double);
published
property MyProperty: TMyClass3 read FMyProperty write SetMyProperty;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyComponentTest3]);
end;
{ TMyComponentTest3 }
constructor TMyComponentTest3.Create(AOwner: TComponent);
begin
inherited;
FMyProperty:= TMyClass3.Create;
end;
destructor TMyComponentTest3.Destroy;
begin
FMyProperty.Free;
inherited;
end;
procedure TMyComponentTest3.SetMyProperty(Value: TMyClass3);
begin
with FMyProperty do …Run Code Online (Sandbox Code Playgroud) 在Mule Studio 3.5中,直接在XML和Flow中,我有以下声明:
<component class="fr.esb.bo.GenerateReportFileComponent" doc:name="BOreport">
<spring:property name="boServices" ref="boServices"/>
</component>
Run Code Online (Sandbox Code Playgroud)
当我用这个启动Mule时,我收到以下错误
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'spring:property'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor, "http://www.mulesoft.org/schema/mule/core":interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-entry-point-resolver-set, "http://www.mulesoft.org/schema/mule/core":abstract-entry-point-resolver, "http://www.mulesoft.org/schema/mule/core":abstract-object-factory, "http://www.mulesoft.org/schema/mule/core":abstract-lifecycle-adapter-factory, "http://www.mulesoft.org/schema/mule/core":binding}' is expected.
Run Code Online (Sandbox Code Playgroud)
我明白了,但是如何将我的boServices bean提供给我的组件?使用定制变压器,这很好用.
我是一名 Delphi 程序员,我正在尝试编写一个应用程序,我想在其中显示来自 telnet 服务器的文本。为了输入要发送的命令,我使用了 TLabeledEdit,为了接收数据,我使用了 TIdTelnet。到目前为止,这没有任何问题。但是我应该使用哪个组件来显示文本以便输出看起来像控制台窗口?我应该使用多行 TLabel 并将其放入 TScrollBox 或 TMemo 并将 TabStop 属性设置为 False 还是有更好的解决方案?
我正在建立一个关于我所做的一些项目的角度应用.我有一个详细页面,显示项目的详细信息.
问题: 当我进入项目详细信息页面时,一切都是正确的.但是,当我切换项目变量(通过使用页面上的导航)时,依赖项组件不会更新,它们无法获得正确的项目ID.
projectdetail.html页面包含所有组件:
<div class="container-content" *ngIf="project">
<div class="projectdetail">
<div class="thumbnail header">
<img [src]="project.img" [alt]="project.name" class="projectImage" />
<div>
<h2>{{project.name}}</h2>
<!--The programming component that you can see in the image-->
<programming-languages [ids]="project.languages"></programming-languages>
</div>
</div>
<div>
<carousel interval="5000" noWrap="false">
<slide *ngFor="let slidez of slides; let index=index">
<img [src]="slidez.image" class="carouselimg" />
<div class="carousel-caption">
<h4>Slide {{slidez.id}}</h4>
<p>{{slidez.text}}</p>
</div>
</slide>
</carousel>
</div>
<div class="thumbnail detail">
<p>{{project.description}}</p>
</div>
</div>
<div class="projects hidden-mm hidden-sm hidden-xs">
<projectsidelist [notShowId]="selectedProjectId"></projectsidelist>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
语言组件代码:
import { Component, Input, OnInit …Run Code Online (Sandbox Code Playgroud) 我有两个组件,我想使用路由参数从一个变量发送到另一个.在我的第一个组件中,我使用此函数发送id:
sendId(id : string) : void {
this.router.navigate(['/component2', id]);
}
Run Code Online (Sandbox Code Playgroud)
我的路由模块如下所示:
const routes: Routes = [
{ path: 'component2/:id', component: Component2},
{ path: '**', redirectTo: '' }
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
Run Code Online (Sandbox Code Playgroud)
在我的第二个组件中,我试图像这样读取它:
import { Router, ActivatedRoute, Params } from '@angular/router';
export class Component2 implements OnInit {
id: string;
constructor(private router: Router, private route: ActivatedRoute) {
}
ngOnInit() {
this.route.params.subscribe(params => { this.id = +params['id'];
});
console.log(this.id);
}
Run Code Online (Sandbox Code Playgroud)
但我收到一个空值.我错过了什么?
我正在更新要使用的React组件:
class SearchFilms扩展了React.Component
代替:
var SearchFilms = React.createClass({
当我运行这个时,我收到以下错误:"无法读取未定义的属性'setState'"
谁能建议我如何更新这个?
class SearchFilms extends React.Component {
//var SearchFilms = React.createClass({
getInitial() {
return {
userInput: ''
};
}
onChange(event) {
this.setState({
userInput: event.target.value
});
this.props.newVal(event.target.value);
}
render() {
var languages = ['Shutter Island', 'Inception', 'Titanic', 'Blood Diamond'];
return (
<div className="row" id="Nav">
<input type="text"
value={this.props.userInput}
onChange={this.onChange}
/>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud) 我曾经create-react-app初始化我的应用程序。然后我npm install semantic-ui-react --save安装了这个包。
我想Grid从https://react.semantic-ui.com/collections/grid#grid-example-divided-number创建这个例子:
我创建了一个名为Grid.js:
import React from 'react'
import { Grid } from 'semantic-ui-react'
const GridExample = () => (
<Grid columns={3} divided>
<Grid.Row>
<Grid.Column>
<p>Lorem Ipsum</p>
</Grid.Column>
<Grid.Column>
<p>Lorem Ipsum</p>
</Grid.Column>
<Grid.Column>
<p>Lorem Ipsum</p>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<p>Lorem Ipsum</p>
</Grid.Column>
<Grid.Column>
<p>Lorem Ipsum</p>
</Grid.Column>
<Grid.Column>
<p>Lorem Ipsum</p>
</Grid.Column>
</Grid.Row>
</Grid>
)
export default GridExample
Run Code Online (Sandbox Code Playgroud)
然后在App.js我导入GridExample:
import React, { Component } from 'react'; …Run Code Online (Sandbox Code Playgroud) 我想在按下 list-profile html doc 中提供的链接后发送一个变量。当前代码不起作用并且崩溃了。如果需要,我可以提供更多细节。
列表-profile.component.html
<div class="col col-sm-4 col-sm-offset-4">
<ul id="list_of_users">
<li class="list-group-item list-group-item-action" *ngFor="let user of users"><a [routerLink]="['/profile', user.id]" routerLinkActive="active" (click)="testFunc(user.id)">{{user.name}}</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
app.module.ts
const appRoutes: Routes = [
{ path: 'addProfile', component: AddProfileComponent },
{ path: 'listProfiles', component: ListProfilesComponent},
{ path: 'profile:id', component: ProfileComponent}
];
Run Code Online (Sandbox Code Playgroud) 我为Angular创建了一个新组件,但我看不到渲染的html.而不是渲染的HTML,我有通往HTML的路径.
这些是我的文件夹结构:
这是我创建的名为server.component.ts的组件:
import { Component } from '@angular/core';
@Component({
selector: 'app-server',
template: './server.component.html'
})
export class ServerComponent {
}
Run Code Online (Sandbox Code Playgroud)
这是组件的html,server.component.html:
<p>Este es mi nuevo componente!!!</p>
Run Code Online (Sandbox Code Playgroud)
在app.component.html中我包含了我的组件的标记:
<div>
<input type = "text" [(ngModel)] = "message" />
<p>{{message}}</p>
<hr>
*<app-server></app-server>*
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的app.module.ts代码,我导入ServerComponent以便以后使用它:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { ServerComponent } from './server/server.component';
@NgModule({ …Run Code Online (Sandbox Code Playgroud) components ×10
angular ×4
delphi ×2
reactjs ×2
class ×1
esb ×1
html ×1
invoke ×1
java ×1
javascript ×1
mule ×1
parameters ×1
routing ×1
semantic-ui ×1
spring ×1
text ×1
winforms ×1