小编Uro*_*ros的帖子

打破Xamarin中任何抛出的异常

我正在Visual Studio 2015中开发一个Xamarin表单的应用程序.当我调试我的应用程序时,我希望它可以在任何抛出的异常中中断.我该怎么办?

xamarin xamarin.forms visual-studio-2015

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

什么是Java的getAndSet的c#等价物

我想编写与此java代码类似的c#代码:

public class Syncer {
    private AtomicBoolean syncInProgress = AtomicBoolean(false);

    // Data is synced periodically and on user request
    // and these two calls may overlap
    public void SyncData() {
        if (flag.getAndSet(true)) {
            return ;
        }

        // Sync data...
        // It is enough that one thread is syncing data

        flag.getAndSet(false);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# multithreading

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

为什么这两个DateTime实例不同?

考虑以下(简化)代码:

DateTime now   = DateTime.Now;
DateTime now2  = new DateTime(now.Year, now.Month, now.Day,
                              now.Hour, now.Minute, now.Second,
                              now.Millisecond, now.Kind);
bool condition = (now <= now2);
Run Code Online (Sandbox Code Playgroud)

由于我复制了nowto 的字段now2,这两个DateTime结构的实例应该是相等的.但是,condition评估为false.为什么?

有什么方法可以更改代码,以便条件评估为true?

.net c# datetime

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

如何使用 ShouldBe 测试 int 相等性

我正在使用 ShouldBe 运行 c# 测试,并且我有以下代码:

int x = 3;
int y = 3;
x.ShouldBeSameAs(y);
Run Code Online (Sandbox Code Playgroud)

问题是它抛出异常:

'Shouldly.ShouldAssertException' 类型的异常出现在 Shouldly.dll 中,但未在用户代码中处理

附加信息:x

should be same as
Run Code Online (Sandbox Code Playgroud)

3

but was
Run Code Online (Sandbox Code Playgroud)

3

如何使用 ShouldBe 测试整数的相等性?

c# shouldly

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

将按钮放在ListView上可扩展到页面之外

我有Xamarin Forms项目。在xaml中,我希望拥有ListView并在其上具有一个可单击且透明的按钮(不透明度= 0.9)。在ListView上方有一个标签,在其下方有一个标签。我使用RelativeLayout放置ListView和透明按钮,并用两个标签将其包装在StackLayout中。问题是ListView扩展到页面之外。

这是我的xaml文件代码:

<StackLayout VerticalOptions="FillAndExpand" BackgroundColor="#4d4d4d" HorizontalOptions="FillAndExpand">
  <Label Text="2600 Michelson" HorizontalOptions="Center" />
  <RelativeLayout VerticalOptions="FillAndExpand">
    <ListView ItemsSource ="{Binding Meters}" HasUnevenRows="True" 
      RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
      RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}" >
    ...
    </ListView>
    <Button Text="Green button" BackgroundColor="#299164" Opacity="0.9"
        RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5, Constant=-50}"
        RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-100}">
    </Button>
  </RelativeLayout>
  <Label Text="This label is not visible" TextColor="#0000ff"></Label>
<StackLayout>
Run Code Online (Sandbox Code Playgroud)

这是屏幕截图:

在此处输入图片说明

我离最终设计还很遥远,但这应该是这样的:

在此处输入图片说明

xamarin xamarin.forms

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

如何定期调用Logstash?

我们正在使用 Logstash 从数据库读取新数据并将其发送到 Elasticsearch。我们希望这种情况定期发生,例如每分钟发生一次。我们如何定期启动 Logstash?在 Linux 上执行此操作的最佳实践是什么?

linux bash elasticsearch logstash

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